Pinterest Add to Cart / Checkout Tracking Code - Cart Pop-up Implementation

I'm trying to add the Pinterest add-to-cart and checkout tracking codes. I've added the add-to-cart code into cart.liquid and using the Pinterest Tag Helper, I can see it only applies when you go on the actual cart page. This does not occur often for my store, as when a customer adds a product to cart, you get the cart pop-up after which they press checkout, so the code never runs. Only if the customer goes back to the cart after going on the checkout, will it run. I'm trying to find the where the code is for the add to cart pop-up, so I can insert the correct code. Please help.

I've added the checkout code in the additional settings box in checkout settings. This only fires after a checkout has occured. I'm unsure if the code I added is correct. Please see it below:

 

{% 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))};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','2620119995167');
pintrk('page');
</script>
<noscript>
<img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=2620119995167&noscript=1" />
</noscript>

<script>
pintrk('track', 'checkout', {value: {{ total_price | money_without_currency }}, order_quantity:1 });
</script>
<noscript>
<img height="1" width="1" style="display:none;" alt="" src="https://ct.pinterest.com/v3/?tid=2620119995167&event=checkout&noscript=1" />
</noscript>
{% endif %}

<script>
var transRev = "{{Enhanced Transaction Revenue}}" != "" ? parseInt("{{Enhanced Transaction Revenue}}") : 0 ;
      var orderQuantity = "{{item.quantity}}" != "" ? parseInt("{{item.quantity}}") : 0;
pintrk('track', 'checkout', {
value: transRev,
order_quantity: orderQuantity
});
</script>

<noscript> 
    <img height="1" width="1" style="display:none;" alt=""
    src="https://ct.pinterest.com/v3/?tid=2620119995167&event=checkout&ed[value]={{Enhanced Transaction Revenue}}&ed[order_quantity]={{item.quantity}}&noscript=1"/>
	</noscript>
0 Likes
New Member
1 0 0

I'm not sure if you've found this already since you posted a while ago, but I found this article helpful.   https://business.pinterest.com/sub/business/guides/Shopify-Pinterest-Tag-guide.pdf

 

The only thing I'm not sure about is that this article uses { em: '{{ customer.email }}' in the script where the Pinterest help pages show {em: '<user_email_address>'} in the scripts.

 

But as far as the add to cart tag, the article referenced above suggests adding the code to the product.liquid, product-template.liquid, or
product-form.liquid. You mentioned in your comment that you were adding code to cart.liquid

0 Likes
New Member
2 0 0

This seems to be the add to cart button code for me, which doesn't align with the help articles, so I'm not sure how to add my last bit of the Pinterest Code

 

 

<script>
// Override default values of shop.strings for each template.
// Alternate product templates can change values of
// add to cart button, sold out, and unavailable states here.
theme.productStrings = {
addToCart: {{ 'products.product.add_to_cart' | t | json }},
soldOut: {{ 'products.product.sold_out' | t | json }},
unavailable: {{ 'products.product.unavailable' | t | json }}
}
</script>

 

DR

0 Likes