• Resolved hakonzen

    (@hakonzen)


    Hi folks! I`m instructed to add a tag for Criteo Marketing on a woo site, but I need to a “dynamic id” for the products, since I cant just add a tag for each product when there are several thousand of them. Anybody knows how to create a dynamic id that fills in the correct product id?

    Here is the tag;
    <!– Criteo Product Tag –>
    <script type=”text/javascript” src=”//static.criteo.net/js/ld/ld.js” async=”true”></script>
    <script type=”text/javascript”>
    window.criteo_q = window.criteo_q || [];
    var deviceType = /iPad/.test(navigator.userAgent) ? “t” : /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Silk/.test(navigator.userAgent) ? “m” : “d”;
    window.criteo_q.push(
    { event: “setAccount”, account: xxxxx }, // You should never update this line
    { event: “setEmail”, email: “##MD5 hashed Email Address of user##” }, // Can be an empty string
    { event: “setSiteType”, type: deviceType },
    {
    event: “viewItem”,
    item: “##Product ID 1##”
    }
    );
    </script>
    <!– END Criteo Product Tag –>

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Nicola Mustone

    (@nicolamustone)

    Automattic Happiness Engineer

    Hello there,
    You can use the PHP product API to get the product ID, something like

    
    global $product;
    
    $product_id = $product->id;
    

    Then you can use that variable in your code. You would have to use PHP to add the code to the header/footer of the website anyway, most likely.

    I also recommend the following places for more development-oriented questions:

    1. WooCommerce Slack Community: https://woocommerce.com/community-slack/
    2. WooCommerce FB group: https://www.facebook.com/groups/advanced.woocommerce/
    con

    (@conschneider)

    Engineer

    Hi there,

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

    Kind regards,

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Dynamic products id’ is closed to new replies.