In order to successfully integrate tracking for your Shopify store, you will need to set up your system by following the instructions in the Quick Setup section in the system and then configure tracking for clicks and conversions by following the guide below.
In your Shopify admin environment, go to the section: Sales channels > submenu Online Store > submenu Themes. In the Current theme box, click on the "three dots" button > click on Edit Code in the dropdown.
In the "Layouts" folder, select the
theme.liquid
file and add the following code just before the</head>
tag.<!-- Trackdesk tracker begin -->
<script async src="//cdn.trackdesk.com/tracking.js"></script>
<script>
(function(t,d,k){(t[k]=t[k]||[]).push(d);t[d]=t[d]||t[k].f||function(){(t[d].q=t[d].q||[]).push(arguments)}})(window,"trackdesk","TrackdeskObject");
trackdesk('YOUR TENANT ID', 'click');
</script>
<!-- Trackdesk tracker end -->Make sure to replace YOUR TENANT ID with your actual tenant ID.
Save changes
Next, in your Shopify admin environment, go to the section: Settings > Customer events.
Add a custom event with the following parameters:
Name - Trackdesk conversion script
Permissions - Select "Not required"
Data sale - Select "Data collected does not qualify as data sale"
Code - paste the code belowvar script = document.createElement('script');
script.type = 'text/javascript';
script.async = true;
script.src = "//cdn.trackdesk.com/tracking.js";
document.head.appendChild(script);
analytics.subscribe("checkout_completed", event => {
(function(t,d,k){(t[k]=t[k]||[]).push(d);t[d]=t[d]||t[k].f||function(){(t[d].q=t[d].q||[]).push(arguments)}})(window,"trackdesk","TrackdeskObject");
trackdesk('YOUR TENANT ID', 'conversion', {
conversionType: 'YOUR SELECTED CONVERSION TYPE',
amount: {
value: event.data.checkout.totalPrice.amount.toString()
},
externalId: event.data.checkout.order.id
});
});Make sure to replace YOUR TENANT ID with your actual tenant ID.
Make sure to replace YOUR SELECTED CONVERSION TYPE with the conversion type you want to use for tracking.
Use Save button to save the changes.
Use Connect button to apply the changes to your website.
Optional: Using Amount without Tax
If you would like to send amount without duties, shipping, and taxes, you can exchange text totalPrice
for subtotalPrice
in the above code snippet.
Testing Your Integration
Please remember to test the creation of clicks and conversions before starting your program. This way, you can verify that tracking has been set up correctly. You can create a test click and conversion by following the steps described here.