Last Updated on by LAUNCHTIP
How to add conversion tracking code to the checkout page only in Shopify
Conversion tracking will help you better understand the full value of your Shopify website and any online marketing campaigns you have running. With conversion tracking in place, you’ll be able to track how many products you are selling and which marketing channel brought the customer to your website.
By adding conversion tracking to your store’s checkout page, you can easily track how often your customers reach checkout and make a purchase. It helps to understand the purchasing trends for your Shopify store.
In order to add conversion tracking code to your store’s confirmation page, you’ll need to understand the following tasks.
Google AnalyticsÂ
Firstly, you’ll need to add your store’s Google Analytics conversion tracking code to the checkout page of your store. Here’s a guide on setting this up.Â
Tracking ordersÂ
Here’s how to add code for tracking orders:Â
- Get the tracking code from a tracking pixel and copy it to the clipboardÂ
- Then, go to Settings in your Shopify adminÂ
- Click on Checkout
- Go to Order Processing and click on Additional ScriptsÂ
- Paste the codeÂ
Add conversion trackingÂ
To add conversion tracking to the confirmation page only , you can add the following script:Â
<script type="text/javascript"> Â Â Â Â Â Â if(Shopify.Checkout.step === 'thank_you') Â Â Â Â Â Â { Â Â Â Â Â Â Â Â /* Start Tracking Code */ Â Â Â Â Â Â Â Â gtag('event', 'conversion', { Â Â Â Â Â Â Â Â Â Â Â Â 'send_to': 'AW-xxxx/xxxx', Â Â Â Â Â Â Â Â Â Â Â Â 'currency': 'USD', Â Â Â Â Â Â Â Â Â Â Â Â 'transaction_id': '{{ checkout.id }}', Â Â Â Â Â Â Â Â Â Â Â Â 'value': "{{ checkout.total_price | money_without_currency }}" Â Â Â Â Â Â Â Â }); Â Â Â Â Â Â Â Â /* End Tracking Code */ Â Â Â Â Â Â } Â Â Â Â </script>
Basic conversion trackingÂ
Let’s say a third party has asked you to integrate a tracking pixel that looks like the following:Â
<img src="https://www.tracking.com/u?amount=<AMOUNT>&order-id=<ORDER_ID>&currency=<CURRENCY>" height="1" width="20" />
According to this code, here are the liquid tags.Â
- The order’s total priceÂ
- The order IDÂ
- CurrencyÂ
When the customer is on checkout’s last page, you will get the following code in the browser:Â
<img src="https://www.tracking.com/pixel.gif?amount=55.34&order-id=4343&currency=USD" height="1" width="1" />
When you get this code, you’ll know that the customer has reached the checkout.