Shopify Add To Cart Tracking Script

 
If you are using the Add To Cart button for your Shopify store, here's how to track the orders with RedTrack:
 
Make sure that landing pages receiving traffic through redtrack.io have additional parameter
added:
 
For example:
 
https://www.yourshopurl.com/pages/ironed-clothes-2mins-ppt-ob?campaignid={campaignid}
&sourceid={sourceid}&tracker=redtrack
 
Then add following JS to this landing page
Parameter that we it will look for in the URL is highlighted pink
Your tracking domain is highlighted green
Your “add to shopping cart” button class is highlighted blue
 
script.png
 
 
----Script start
 
<script type="text/javascript">
function getParameterByName(name, url) {
if (!url)
url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results)
return null;
if (!results[2])
return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
window.addEventListener('DOMContentLoaded', function () {
if (getParameterByName("redtrack", document.location.href) != null) {
var btns = document.querySelectorAll('.amazon-aff');
for (var i = 0; i < btns.length; i++) {
btns[i].href = "http://t.yourshopurl.com/click";
}
}
}
});
</script>
 
-------- Script finish -------------
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.