This article is also available in:
You can integrate Pinterest Tag into your online store to help you understand more about customer behavior and the traffic source. Pinterest tag collects data about how customers are using your online store pages, so that you can more effectively plan your ad campaigns to find new customers. This part will help you install the Pinterest tag on ShopBase in a few easy steps!

In this section

A. Get your Pinterest Tag ID
B. Install the Pinterest Tag

A. Get your Pinterest Tag ID

Step by Step Tutorial

Log into your Pinterest business account

Click Ads at the top of the screen, then click Conversions


Click Add Code


Copy the Pinterest tag of your Pinterest Ads account



B. Install the Pinterest Tag

Step by Step Tutorial

On your store admin, go to Online Store > Preferences

Scroll to the Additional scripts > Head section and paste this scripts.

<script>
const pinterestId = "pinterestId" //Insert your pinterest tag ID
const email = 'email' // Insert your email
!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', pinterestId, {em: email});
pintrk('page');
window.sbsdk.ready(function() {
window.sbsdk.cart.onAdd(function(payload) {
let cart = window.sbsdk.cart.get()
let product_added = cart.items.find(item => item.variant_id == payload.variant_id)
if(product_added) {
pintrk('track', 'addtocart', {
value: product_added.price,
order_quantity: payload.qty,
currency: cart.currency,
});
}else {
let order = window.sbsdk.checkout.getOrder()
pintrk('track', 'addtocart', {
value: payload.post_purchase_price,
order_quantity: payload.qty,
currency: cart.currency,
});
pintrk('track', 'checkout', {
order_id: order.id,
value: payload.post_purchase_price,
order_quantity: payload.qty,
currency: cart.currency,
product_id: payload.variant_id,
});
}
});
window.sbsdk.cart.onUpdate(function(payload) {
let cart = window.sbsdk.cart.get()
let product_added = cart.items.find(item => item.variant_id == payload.variant_id)
pintrk('track', 'addtocart', {
value: product_added.price,
order_quantity: payload.qty,
currency: cart.currency,
});
});
window.sbsdk.page.onContextUpdate(function(context) {
switch (context.type) {
case 'home':
// push event tracking pinterest at home page
break;
case 'product':
pintrk('track', 'pagevisit');
break;
case 'process_checkout':
// Inject code tracking at checkout page here
break;
case 'post_checkout':
// Inject code tracking at thank you page here
let order = window.sbsdk.checkout.getOrder()
let collection_titles = []
if(order.items.length > 0 ) {
for(let x in order.items) {
let collections = order.items[x].collections
for(let y in collections) {
collection_titles[y] = collections[y].title
}
}
let line_items = order.items.map(function(item) {
return item = {
'product_category': collection_titles,
'product_name': item.product_title,
'product_id': item.product_id,
'product_quantity': item.qty,
'product_price': item.item_price,
}
})
let qtyBlock = document.getElementsByClassName('checkout-product-thumbnail__quantity');
let qty = 0
for (let i = 0; i < qtyBlock.length; ++i) {
qty += parseInt(qtyBlock[i].innerHTML)
}
let totalPrice = document.getElementsByClassName('payment-due__price')[0].innerHTML
totalPrice = totalPrice.substring(1)
totalPrice = totalPrice.substring(0, totalPrice.length - 3)
pintrk('track', 'checkout', {
order_id: order.id,
value: totalPrice,
order_quantity: qty,
currency: window.sbsdk.cart.get().currency,
line_items: line_items
});
}
break;
default:
break;
};
});
});
</script>



Replace pinterestId in Line 2 with your Pinterest Tag ID in section A and replace email in line 3 with your Pinterest logging email.

Click Save

Related articles
Integrate Klaviyo with your store
Set up Facebook Pixel IDs and Conversions API in ShopBase
Set up Google Analytics
Track Google Ads Conversions with ShopBase
How to install Twitter conversion tracking ID on ShopBase
How to install Bing Ads Conversion Tracking on ShopBase
Install Hotjar Tracking Code
Add codes of other tracking tools to ShopBase store
Was this article helpful?
Cancel
Thank you!