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 have additional parameter
For example:{campaignid}
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 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 = "";
-------- Script finish -------------
Have more questions? Submit a request


Please sign in to leave a comment.