Knowledge Base      


How do I add tracking pixels or JavaScript code to Shopify?


In this article, we’re going to show you where to install tracking pixels and tracking code in Shopify. But, before you read further, if you don’t already have a good understanding of where to install tracking pixels on an HTML page, the rest of this document will make more sense if you review this article first:
 
What are tracking pixels and tracking code?

To begin tracking Shopify sales, just follow the steps outlined below…






Step 1 - Add your Click Tracking Code to the theme.

Copy your click tracking code below:
 
<script>
    var clickmagick_cmc = {
        uid: '[USERID]',
        hid: '[HID]',
    }
</script>
<script src='//cdn.clkmc.com/cmc.js'></script>


And inside of Shopify click on “Online Store” 

 

 
Click on “Actions” followed by “Edit Code”
 
 

 
Under “Layout” select the theme.liquid file and add the Click Tracking Code after the opening <head> tag.
 
 

  
Note: If you plan on getting traffic organically, you’ll want to use the Organic Click Tracking code instead of the code shown above. For more info, please checkout the article below:

How do I track organic traffic with Campaigns?


 
Once that is done, Save your changes.

Step 2 - Add your Sales Conversion Code.

To do this, just click on “Settings” and click “Checkout.”

 

 
In the “Order Processing” section in the “Additional scripts” add the Sales Conversion Code below:

    <script>
        var clickmagick_cmc = {
            uid: '[USERID]',
            hid: '[HID]',
            cmc_goal: 's',
            cmc_ref: '{{ order_number }}',
            cmc_amt: '{{ total_price | money_without_currency }}',
        }
    </script>
 <script src='//cdn.clkmc.com/cmc.js'></script>


And that’s it! With the above setup you can now track your Shopify Sales.

 
 

Adding your Sales Pixel.

To do this, just click on “Settings” and click “Checkout.”

 

 
In the “Order Processing” section in the “Additional scripts” add the Sales Conversion Code below:

<script>
var cmPixel = document.createElement('img');
cmPixel.src = "//www.clkmg.com/api/s/pixel/?uid=[USERID]&ref={{ order_number }}
&amt={{ total_price | money_without_currency }}";
</script>
<noscript><img height="1" width="1" style="display:none"

src="//www.clkmg.com/api/s/pixel/?uid=[USERID]&ref={{ order_number }}
&amt={{ total_price | money_without_currency }}"
/></noscript>


Article 594 Last updated: 08/27/2021 5:01:00 PM
https://www.clickmagick.com/kb/?article=594