If you are not using the Google App in Shopify with GA enabled already, the following code may be what you need.
- First, go to: Settings > Checkout > Order status page (toward the bottom).
- Then, copy and paste the following code into the “Order status page” section.
- Replace
G-XXXXXXXXXX
with your GA4 measurement ID. - Finally, Click “Save“.
However, keep in mind Shopify will remove the additional scripts section on August 28, 2025. I recommend using custom pixels or the Google Shopify App and turning on conversion tracking under Apps > Google & YouTube > Settings > Conversion tracking.
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){window.dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
</script>
{% if first_time_accessed %}
<script>
gtag('event', 'purchase', {
'send_to':'G-XXXXXXXXXX',
"transaction_id": '{{ checkout.order_id }}',
"affiliation": "Shopify Shopping Cart",
"value": {{ checkout.total_price | divided_by: 100.0 }},
"currency": '{{ checkout.currency }}',
"tax": {{ checkout.tax_price | divided_by: 100.0 }},
"shipping": {{ checkout.shipping_price | divided_by: 100.0 }},
"items": [{% for line_item in line_items %}{
"item_id": '{{ line_item.product_id }}',
"item_name": '{{ line_item.title }}',
"item_variant": '{{ line_item.variant_id }}',
"quantity": {{ line_item.quantity }},
"price": {{ line_item.final_price | divided_by: 100.0 }},
"affiliation": '{{ line_item.vendor }}',
"discount": {{ line_item.line_level_total_discount | divided_by: 100.0 }}
}{% unless forloop.last %},{% endunless %}{% endfor %}]
});
</script>
{% endif %}
Shopify Updates
Finally, as part of ongoing improvements Shopify is making to Checkout and the Thank You page, you need to check to your Additional Scripts to ensure that your conversion tracking and downstream systems are working correctly.
What you need to do
Replace “checkout.order_number” with “checkout.order_id” in Additional Scripts and similarly update any downstream systems that rely on this data.
In the code above, I’ve already replaced checkout.order_number
with checkout.order_id
but you still need to check any downstream systems if you have them.
Leave a Reply