less than a minute read • Updated 39 minutes ago
Add custom tracking code to the web receipt
How to add conversion tracking, analytics, or affiliate tracking code that fires only the first time a customer sees their receipt.
Most conversion tracking scripts (analytics, ad platforms, affiliate programs) need to fire once per completed transaction — not every time the receipt is viewed. Wrapping your tracking code in the first_receipt_display variable ensures it only fires the first time a customer sees their receipt.
Steps
{% if first_receipt_display %}
<!-- Insert Tracking Code Here -->
{% endif %}
Notes
first_receipt_displayistrueonly the first time the receipt loads for a given transaction — if the customer reloads the page or revisits the receipt later, the code inside theifblock won’t run again.The custom footer runs on the cart, checkout, and receipt templates, so the
first_receipt_displaycheck is what scopes the code to the receipt specifically.