Last Updated on by Dan S
Originally Published February 12, 2022.
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 checkout page using the latest Shopify standards, you’ll need to understand the following tasks.
Google Analytics
Firstly, you’ll need to add your store’s Google Analytics conversion tracking code using Shopify’s Customer Events framework. Here’s a guide on setting this up using Shopify’s Customer Events and custom pixels system.
Tracking orders
Shopify has updated how tracking scripts should be implemented. The deprecated Additional Scripts section and checkout.liquid are no longer supported. Follow these steps to set up conversion tracking:
- Go to Settings in your Shopify admin
- Click Customer Events
- Click Custom pixels
- Click Add pixel to create a new custom pixel or edit an existing one
- Paste your tracking code into the custom pixel code editor
- Click Save, then click Connect pixel to activate it
- Test using browser developer tools or the Shopify Pixel Helper
checkout.liquid scripts and Additional Scripts are no longer editable. All conversion tracking must now use the Customer Events framework with custom pixels or app pixels. If you haven’t migrated yet, legacy tracking methods have stopped working.
Add conversion tracking
To add conversion tracking to the thank you page only, you can create a custom pixel that subscribes to the checkout_completed event:
analytics.subscribe("checkout_completed", (event) => {
/* Start Tracking Code */
gtag('event', 'conversion', {
'send_to': 'AW-xxxx/xxxx',
'currency': event.data.checkout.currencyCode,
'transaction_id': event.data.checkout.order.id,
'value': event.data.checkout.totalPrice.amount
});
/* End Tracking Code */
});Security sandbox tracking environment
Shopify now runs all checkout customizations and pixels in a secure sandboxed environment. This improves safety, performance, and customer privacy but also means your code must comply with strict standards. Custom pixels cannot access DOM elements directly or render user interface elements, but they can subscribe to standardized customer events.
Basic conversion tracking
Let’s say a third party has asked you to integrate a tracking pixel like this one:
<img src="https://www.tracking.com/u?amount=<AMOUNT>&order-id=<ORDER_ID>&currency=<CURRENCY>" height="1" width="1" />
To implement this in a custom pixel, you would subscribe to the checkout_completed event and access the following data:
- The order’s total price from event.data.checkout.totalPrice.amount
- The order ID from event.data.checkout.order.id
- Currency from event.data.checkout.currencyCode
When the customer completes checkout, your custom pixel will fire with the correct data:
analytics.subscribe("checkout_completed", (event) => {
const img = document.createElement('img');
img.src = `https://www.tracking.com/pixel.gif?amount=${event.data.checkout.totalPrice.amount}&order-id=${event.data.checkout.order.id}¤cy=${event.data.checkout.currencyCode}`;
img.height = 1;
img.width = 1;
document.body.appendChild(img);
});When the customer completes checkout, the code above will ensure the pixel fires with the correct data using secure and updated methods.
Post-purchase upsell tracking
If you’re using post-purchase upsells with Checkout Extensibility apps, you can track conversions via both the checkout_completed event (which fires on the first upsell offer page) and additional purchase events for enhanced insight:
analytics.subscribe("checkout_completed", (event) => {
// Track initial purchase completion
console.log('Purchase completed', event.data.checkout);
});Troubleshooting
- The Additional Scripts section is now view-only as of August 28, 2025. All tracking must be migrated to Customer Events with custom pixels or app pixels.
- Use your browser’s developer tools Network tab to validate that the
checkout_completedevent has fired and your tracking code executed successfully. - You can also use the Shopify Pixel Helper to test your custom pixels and verify events are being tracked correctly.
- Note: Google Tag Manager cannot debug Customer Events due to the sandboxed nature of Shopify’s checkout environment. Avoid relying on GTM preview mode—inspect network logs manually instead using your browser’s developer console.
- If migrating from old tracking methods, make sure to disconnect legacy pixels to avoid duplicate conversion tracking.






