How to add the Pinterest tag to your Shopify store manually
The Pinterest tag is a piece of JavaScript code you put on your website to gather conversion insights and build audiences to target based on actions they’ve taken on your site.
If you are a user of Shopify platform, following the below steps to add the Pinterest tag to Shopify manually.
Step 1: Base code
- From your Shopify admin, click Online Store and then Themes.
- Navigate to the theme you want to edit and click Actions then Edit Code.
- In the Layout directory, click theme.liquid.
- Scroll until you see
</head>
and paste this code above it:123456789101112131415<script type="text/javascript">!function(e){if(!window.pintrk){window.pintrk=function(){window.pintrk.queue.push(Array.prototype.slice.call(arguments))};varn=window.pintrk;n.queue=[],n.version="3.0";vart=document.createElement("script");t.async=!0,t.src=e;varr=document.getElementsByTagName("script")[0];r.parentNode.insertBefore(t,r)}}("https://s.pinimg.com/ct/core.js");pintrk('load','YOUR_TAG_ID', { em: '{{ customer.email }}', });pintrk('page');</script><noscript><img height="1" width="1" style="display:none;" alt=""src="https://ct.pinterest.com/v3/?tid=YOUR_TAG_ID&noscript=1" /></noscript> - Replace YOUR_TAG_ID with your own unique tag ID.
- To find this, navigate to Ads Manager and click on Ads, then find Conversion Tracking and click Generate Pinterest Tag.
- Navigate to your conversion tracking overview and find the details section.
- Copy the 13 digit number below Unique Tag ID and paste it in place of YOUR_TAG_ID in the code.
Step 2: Checkout code
- From your Shopify admin, click Settings and then click Checkout.
- In the Order processing section, find the Additional scripts text box.
- Paste the following tracking code into the text box; if there is already code in this box, paste your tracking code after it.123456789101112131415161718192021222324252627282930{% if first_time_accessed %}<script type="text/javascript">!function(e){if(!window.pintrk){window.pintrk=function(){window.pintrk.queue.push(Array.prototype.slice.call(arguments))};varn=window.pintrk;n.queue=[],n.version="3.0";vart=document.createElement("script");t.async=!0,t.src=e;varr=document.getElementsByTagName("script")[0];r.parentNode.insertBefore(t,r)}}("https://s.pinimg.com/ct/core.js");pintrk('load','YOUR_TAG_ID', { em: '{{ customer.email }}', });pintrk('page');</script><noscript><img height="1" width="1" style="display:none;" alt=""src="https://ct.pinterest.com/v3/?tid=YOUR_TAG_ID&noscript=1" /></noscript><script>pintrk('track', 'checkout',{value: {{ total_price | money_without_currency }},currency: '{{ currency }}',order_quantity: 1,order_id: {{ checkout.id }}});</script><noscript><img height="1" width="1" style="display:none;" alt=""src="https://ct.pinterest.com/v3/?tid=YOUR_TAG_ID&event=checkout&noscript=1"/></noscript>{% endif %}
- Remember to replace YOUR_TAG_ID with the unique tag ID that was generated in Ads Manager.
Step 3: Add to cart code
- From your Shopify admin, click Online Store then Themes.
- In the current theme you’re using, click Actions and Edit code.
- Under Templates look for code files named product.liquid or product-template.liquid or product-form.liquid and open it. Note that this may vary depending on the theme you have installed, but it’s most common to see add to cart button code in the products.liquid file or equivalent.
- Search the file for addtocart.
- Place the following code within the ending caret of the
<button>
or<input>
element.1onclick="pintrk('track', 'addtocart');" - Click Save and you are done.
Thank you. It worked! Only the 3. part is not working for me, i guess its my third party theme!
Appreciate it
Nice article thank you very much. Guys for those of you who are not filling comfortable dealing with code you can just use this App https://apps.shopify.com/pinterest-pixel-helper?ref=hura. And if anything not to your licking (unusual theme for example that needs adjustment) contact the support and we will take care of it
Hi
what’s in it for you guys, with the app. Do you collect data this way?
once the pixel is installed, can I remove the app again?
To be honest we still have not decided maybe some small monthly fee if shop can aford it like 5 dolars. The app only works if it’s installed of course but the good thing tha app does not mess with theme liquid so if uninstalled it leavs no trace