Integrating Trackdesk with your Shopify store allows you to track affiliate clicks and conversions. By setting up this integration, you can automatically monitor affiliate-generated traffic and attribute sales directly from your checkout, ensuring accurate tracking and commission payouts for your affiliate program.
⚠️ Important: Before you begin, you must set up your system by following the instructions in the Quick Setup section within the Trackdesk platform.
1. Before You Start
Make sure you have the following information from your Trackdesk account ready:
Your Tenant ID.
Your Conversion Type (e.g., sale, lead).
Your Revenue Origin ID.
2. Step-by-Step Integration
Step 1: Set Up Click Tracking
To track when a user arrives at your store via an affiliate link, you need to add the click tracking script to your Shopify theme.
In your Shopify admin dashboard, go to Sales channels > Online Store > Themes.
In the Current theme box, click on the three dots button and select Edit Code from the dropdown menu.
In the the "Layouts" folder, click on the theme.liquid file to open it.
Copy the following base tracking code and paste it just before the closing
</head>tag. Remember to replaceYOUR_TENANT_IDwith your actual Tenant ID.
<!-- 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 -->
In the code you just pasted, replace
YOUR_TENANT_IDwith your actual Trackdesk Tenant ID.
Click Save in the top right corner to apply the changes.
Step 2: Set Up Conversion Tracking
To record successful purchases, you need to configure a Shopify Custom Pixel.
In your Shopify admin, go to Settings > Customer events.
Click Add custom pixel and name it Trackdesk conversion script.
Set Permissions to "Not required" and Data sale to "Data collected does not qualify as data sale".
In the Code field, paste the following script:
var 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
});
});
Replace
YOUR_TENANT_IDandYOUR_SELECTED_CONVERSION_TYPE(e.g., 'sale') with your actual data.
Click Save and then click the Connect button to apply the changes to your website.
3. Optional Configurations
Using Amount Without Tax
If you prefer to track revenue excluding taxes, shipping, and duties, modify the conversion script in Step 2 by replacing totalPrice with subtotalPrice.
Coupon Tracking
If you want to attribute conversions via Shopify discount codes, use the following code in your Customer Event pixel instead of the one provided in Step 2:
var 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");
const discountApplications = event.data.checkout.discountApplications || [];
const discountTitles = discountApplications.map(discount => discount.title);
trackdesk('YOUR_TENANT_ID', 'conversion', {
couponCodes: discountTitles,
conversionType: 'YOUR_SELECTED_CONVERSION_TYPE',
revenueOriginId: 'YOUR_REVENUE_ORIGIN_ID',
amount: {
value: event.data.checkout.totalPrice.amount.toString()
},
externalId: event.data.checkout.order.id
});
});Ensure you replace YOUR_REVENUE_ORIGIN_ID with the ID found in your Trackdesk account settings
4. Advanced
If you need to pass additional Shopify variables (like customer tags or currency), refer to the Shopify Web Pixels API documentation for a full list of available properties.
5. Testing & Troubleshooting
Testing:
Before officially launching your affiliate program, we highly recommend running a test to verify everything is set up correctly.
Generate a test affiliate link in your Trackdesk account and click on it.
Complete a test purchase on your Shopify store to trigger a conversion.
Go to your Trackdesk dashboard and verify that both the click and the resulting conversion were recorded correctly.
Troubleshooting:
Check Variables: Ensure
Tenant ID,Conversion Type, andRevenue Origin IDexactly match your Trackdesk settings (case-sensitive).
Pixel Status: Confirm that the custom pixel in Shopify Settings > Customer events is marked as Connected.
