Track customers purchasing from your ShopBase store and optimize your ad campaigns on different channels by inserting the tracking code on the thank-you page.

There're many uses of scripts on your Thank-you page. Tracking scripts are provided by a third-party, and are used as an Additional scripts in your ShopBase admin.

This is an advanced tutorial, if you're not familiar with proceeding with coding and resolving potential conflicts, please contact us via Live Chat box for better support.
In this article
A. How to add tracking code to your thank-you page
B. Facebook Pixel
C. Google Analytics conversion tracking
D. Twitter tracking code

A. How to add tracking code to your thank-you page

From your store Admin Dashboard, go to Online Store >> Preferences
Scroll to the Additional scripts >> Head section and paste this scripts.

<script>
window.sbsdk.ready(function() {
window.sbsdk.page.onContextUpdate(function(context) {
if (context.type === 'post_checkout') {
// Inject code tracking here
}
});
});
</script>

Replace the tracking scripts (provided by a third-party) in the // Inject code tracking here section
Save and you are done.

B. Facebook Pixel

You can set up Facebook Pixel to track when customers visit your checkout and finish purchasing, check this guide for more details>>

C. Google Ads conversion tracking

Other than Facebook Pixel, you can use Google Analytics conversion tracking for customers' checkout process. More details, please refer to article Track Google Ads Conversion with ShopBase.

D. Twitter tracking code
Kindly add the code given below the line as instructed in this image following:



Here's the Twitter tracking code:

<script>
window.sbsdk.ready(function() {
window.sbsdk.page.onContextUpdate(function(context) {
if (context.type === 'post_checkout') {
const orderId = window.sbsdk.checkout.getOrder().id;
const twtId = '048hp';
const twtEventName = 'purchase';
const paramsDataTrack = {
orderId: orderId,
}
!function(e,t,n,s,u,a){e.twq||(s=e.twq=function(){s.exe?s.exe.apply(s,arguments):s.queue.push(arguments);
},s.version='1.1',s.queue=[],u=t.createElement(n),u.async=!0,u.src='//static.ads-twitter.com/uwt.js',
a=t.getElementsByTagName(n)[0],a.parentNode.insertBefore(u,a))}(window,document,'script');
twq('init', twtId);
twq('track', twtEventName, paramsDataTrack);
}
});
});
</script>

To get the Order ID in checkout page or thank you page, for more details, please refer to this: https://developers.shopbase.com/build-a-theme/storefront-sdk
To change text with your twitter tracking ID, for example: 048hp
To change text with name of event you want, for example: Pageview, Purchase
Add params key you want to sent event, for example: name : abc , cartQuantity : 1
Was this article helpful?
Cancel
Thank you!