Placing the Pinterest Pixel for Dynamic Shopping Ads

10/19/2019

Placing the Pinterest pixel base code

The basecode should fire on every page of your website, make sure to place it above any of the event codes below.

Replace the [ INSERT CONVERSION ID HERE ] placeholders in the code below with your unique Pinterest conversion id.

You find your conversion id in Pinterest under Ads > Conversions. The number under your Pinterest Tag is your unique id.

                
    <!-- Pinterest Tag -->
    <script>
        !function(e){if(!window.pintrk){window.pintrk = function () {
        window.pintrk.queue.push(Array.prototype.slice.call(arguments))};var
        n=window.pintrk;n.queue=[],n.version="3.0";var
        t=document.createElement("script");t.async=!0,t.src=e;var
        r=document.getElementsByTagName("script")[0];
        r.parentNode.insertBefore(t,r)}}("https://s.pinimg.com/ct/core.js");
        pintrk('load', '[ INSERT CONVERSION ID HERE ]');
        pintrk('page');
    </script>
    <noscript>
        <img height="1" width="1" style="display:none;" alt=""
        src="https://ct.pinterest.com/v3/?tid=[ INSERT CONVERSION ID HERE ]&noscript=1" />
    </noscript>
    <!-- end Pinterest Tag -->
                
            

Pagevisit Event

Place the “Pagevisit” event on all product pages.

                
    <script>
    pintrk('track', 'pagevisit', {
        line_items: [
        {
            product_name: {{ product.title }},
            product_id: {{ product.id }},
            product_price: {{ product.price }},
        },
        ]
    });
    </script>
                
            

Add to Cart Event

If you want the “Add to Cart” event to fire on the button click on product pages, place the eventcode below on button click. Alternatively, you can fire the code below when a user visits the Cart page.

                
    <script>
    pintrk('track', 'addtocart', {
        line_items: [
        {% for item in line_items %}
        {
            product_name: {{ item.title }},
            product_id: {{ item.id }},
            product_price: {{ item.price }},
            product_quantity: {{ item.quantity }}
        },
        {% endfor %}
        ]
    });
    </script>
                
            

Checkout Event

Place the checkout event in Shopify Settings > Checkout > Additional Scripts. Make sure to place the pixel base code from step 1 before this event code.

                
    <script>
    pintrk('track', 'checkout', {
        value: {{ total_price | money_without_currency }},
        order_quantity: 2,
        currency: 'USD',
        line_items: [
        {% for item in line_items %}
        {
            product_name: {{ item.title }},
            product_id: {{ item.id }},
            product_price: {{ item.price }},
            product_quantity: {{ item.quantity }}
        },
        {% endfor %}
    
        ]
    });
    </script>
                
            

Pixel testing

After placing the pixels on your website, make sure to test each pixel events with the Pinterest Tag Helper extension for Google Chrome.

Do you need more frequent product feed updates without having to manually click the button?
Contact us for a custom solution.