Overview
Shopify provides a Post-purchase page > Additional scripts field in Settings > Checkout of the Shopify admin. This field is the only supported way to track conversions that happen on post-purchase upsell pages (e.g. when a buyer accepts an upsell).
⚠️Zipify Support can’t help with modifying or editing post-purchase page scripts. If you require further assistance, you can post in the Shopify Community or hire a Shopify Expert.
Why this field exists
This field exists primarily to track post-purchase offer conversion(s).
📝 With Customer Events, the initial order conversion is already tracked automatically (via the checkout_completed
event). As a result, this field is now only needed for tracking post-purchase offer conversions.
Pixels in Shopify
Pixels can be added to your store in two ways:
App pixels – installed automatically through marketing/analytics apps.
Custom pixels – manually created and managed in the Customer events section of your Shopify admin.
Tracking behavior in Customer Events
Initial Order: Customer Events can track the initial purchase conversion (
checkout_completed
), which fires on the first post-purchase page load.Post-purchase Offers: These conversions are not tracked with Customer Events alone.
About CheckoutAmended
CheckoutAmended
is a Shopify Checkout Extension event that fires when an order is updated after checkout (e.g. a post-purchase upsell is accepted).This event is not supported in the Customer Events (pixels manager).
To capture upsell “Purchase” events, you must use the Post-purchase page Additional scripts field.
📝Important Notes
The only HTML tag allowed in this field is
<script>
. Adding any other HTML tag(s) can prevent other tracking scripts included in this field from firing correctly.Shopify Liquid isn’t supported.
The script runs within a sandbox and isn't included on the main page. This means you can’t directly access or manipulate the parent checkout page DOM, nor can you access storefront cookies that are scoped to the main site. You aren't able to add code to this field to customize your post-purchase offer page(s).
This sandboxing is intentional — it’s a security measure designed by Shopify to ensure the script can only execute in the post-purchase context and only for tracking/analytics.
Example: Facebook Pixel for post-purchase offer tracking
For the native Facebook Pixel (Meta Pixel) integration for Shopify, the "Purchase" event for the initial order fires automatically when the post-purchase upsell 1 page loads. Therefore, only event tracking for the post-purchase offer(s) is needed to be added, if desired.
Below is an example script for the Facebook Pixel that can be used to track the "Purchase" event for post-purchase offer conversions only:
<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', 'YOUR_PIXEL_ID');
</script>
<script>
Shopify.on('CheckoutAmended', function(newOrder, previousOrder) {
const prevOrder = previousOrder.order || previousOrder;
const oldItems = prevOrder.lineItems.map(function (line) {
return line.id;
});
const addedItems = newOrder.lineItems.filter(function (line) {
return oldItems.indexOf(line.id) < 0;
});
if (addedItems.length === 0) return;
const newItem = addedItems[0];
fbq('track', 'Purchase', {
content_type: 'product_group',
content_ids: [newItem.product.id],
value: newItem.finalPrice,
num_items: newItem.quantity,
currency: newOrder.currency
});
});
</script>
📝Make sure to include your Facebook Pixel ID where YOUR_PIXEL_ID
is shown in the example script above.
Example: GA4 (Google Analytics) for post-purchase offer tracking
For the native GA4 (Google Analytics) integration for Shopify, the "purchase" event for the initial order fires automatically when the post-purchase upsell 1 page loads. Therefore, only event tracking for the post-purchase offer(s) is needed to be added, if desired.
Below is an example script for Google Analytics (GA4) that can be used to track the "purchase" event for post-purchase offer conversions only:
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXX');
</script>
<script>
Shopify.on('CheckoutAmended', function(newOrder, previousOrder) {
const prevOrder = previousOrder.order || previousOrder;
const oldItems = prevOrder.lineItems.map(function (line) {
return line.id;
});
const addedItems = newOrder.lineItems.filter(function (line) {
return oldItems.indexOf(line.id) < 0;
});
if (addedItems.length === 0) return;
const newItem = addedItems[0];
gtag('event', 'purchase', {
'value': newItem.finalPrice,
'currency': newOrder.currency,
'items': [
{
'id': newItem.product.id,
'quantity': newItem.quantity,
'price': newItem.finalPrice
}
]
});
});
</script>
📝Make sure to include your G-Tag ID where G-XXXXXXXXX
is shown in the two locations of the example script above.