How it works
Because the Zonos Checkout runs inside an iframe on a different origin, it
cannot directly access your page's gtag function. The relay system solves this
with a two-step handshake (steps 1-2) followed by event forwarding (step 3):
- Checkout pings the parent -- When the checkout loads inside the iframe, it sends a message to the parent window indicating it's ready to relay events.
- Parent acknowledges -- The relay script on your page receives the ping, detects your existing GA4 configuration, and signals back that it's ready to receive events.
- Events are forwarded -- As shoppers progress through checkout, each
analytics event is sent via
postMessageto your page, where the relay script forwards it togtag.
All messages are validated against trusted Zonos origins (zonos.com and
iglobalstores.com) over HTTPS only.
Prerequisites
- A GA4 property with a measurement ID (format:
G-XXXXXXXXXX). You can create one in Google Analytics. - A legacy Checkout integration that loads Zonos Checkout in an iframe on your page.
Setup
Step 1: Add the GA4 tag to your page
If you don't already have GA4 installed on your site, add the standard Google
Analytics 4 tag to the <head> of the page that hosts the Checkout iframe.
Replace G-XXXXXXXXXX with your own measurement ID.
<!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script> <script> window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } gtag("js", new Date()); gtag("config", "G-XXXXXXXXXX");</script>Note: If your site already has the GA4 tag installed (e.g., through Google Tag Manager or a direct snippet), you can skip this step. The relay script will use your existing
gtagfunction.
You can find this snippet in your GA4 property under Admin -> Data Streams -> select your stream -> View tag instructions -> Install manually.
Step 2: Pass your measurement ID to Zonos Checkout
Tell Zonos Checkout which GA4 measurement ID to use by setting
window.Zonos.googleAnalyticId inside your Checkout's customHTML. The Zonos
dashboard exposes a customHTML editor under Checkout settings -- add a
<script> tag like this:
<script> window.Zonos.googleAnalyticId = "G-XXXXXXXXXX";</script>This value is sent to the parent during the relay handshake. If your parent
page doesn't already have gtag loaded, the relay script will inject the GA4
base tag for you using this ID.
Step 3: Add the Zonos analytics relay script
Add the following script tag to the same page, after the GA4 tag. This script
listens for analytics events from the Zonos Checkout iframe and forwards them to
your gtag.
<script async src="https://cdn.jsdelivr.net/npm/@zonos/elements/dist/scripts/analyticsRelayOnInit.js"></script>Complete example
Here's what the full setup looks like in your page's <head>:
<head> <!-- ... your existing head tags ... --> <!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX" ></script> <script> window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } gtag("js", new Date()); gtag("config", "G-XXXXXXXXXX"); </script> <!-- Zonos analytics relay for iframe checkout --> <script async src="https://cdn.jsdelivr.net/npm/@zonos/elements/dist/scripts/analyticsRelayOnInit.js" ></script></head>That's it. Once both scripts are on your page, the relay script automatically completes the handshake with the checkout iframe and forwards all checkout funnel events to your GA4 property.
GA4 events reference
Zonos Checkout emits the following events through the relay. All events include
an isTestMode flag and the checkoutSessionId.
| Event↕ | Trigger↕ | Additional metadata↕ |
|---|---|---|
zonos-checkout-start | Checkout opens | -- |
zonos-checkout-customer-info | Shopper enters customer information | -- |
zonos-checkout-shipping-info | Shopper selects a shipping method | serviceLevelId |
zonos-checkout-payment-info | Shopper enters payment details | paymentMethod |
zonos-checkout-payment-fail | Payment attempt fails | -- |
zonos-checkout-success | Order completes successfully | transaction_id, currency, value, items |
zonos-checkout-close | Shopper closes checkout | -- |
purchase | Order completes (GA4 standard e-commerce event) | transaction_id, currency, value, items |
Purchase event metadata
The purchase event follows the
GA4 e-commerce purchase event
schema:
| Field↕ | Description↕ |
|---|---|
transaction_id | Zonos order ID or checkout session ID |
currency | Three-letter currency code (e.g., USD) |
value | Total order value |
items | Array of cart items, each with item_id, item_name, price, and quantity |
Debugging
To enable debug logging for the relay script, add the zonosDebug=1 query
parameter to your page URL:
https://www.yourstore.com/checkout?zonosDebug=1Open your browser's developer console to see detailed logs of the relay handshake and forwarded events. This is useful for verifying that:
- The relay script receives the ping from the checkout iframe.
- GA4 is configured with the correct measurement ID.
- Events are being forwarded to
gtag.
Common questions
Do I need to modify my createTempCart API call?
No. The relay system works independently of the createTempCart API. You only
need to add the GA4 tag and the relay script to your page.
What if I already use footerHTML for Google Analytics?
The footerHTML parameter in the
createTempCart API
injects scripts inside the checkout iframe, which is limited to tracking
page-level events within the iframe origin. The relay approach is recommended
because it sends events to your own GA4 property on your domain, giving you full
funnel visibility in a single property.
You can safely remove any GA4 scripts from footerHTML after setting up the
relay.
Does this work with GA4 debug mode in Google Analytics?
Yes. You can use zonosDebug=1 to enable relay script logs in your browser's developer console, and use the
GA4 DebugView in Google
Analytics to verify events in real time.
Are test orders tracked?
All events include an isTestMode field. When Checkout is in test mode, events
are still sent to GA4 but flagged with isTestMode: true. You can filter these
out in GA4 using custom dimensions if needed.
Google Analytics 4 for iframe Checkout
Track the full checkout funnel with GA4 when using an iframe-based legacy Checkout integration.
Merchants using the legacy Checkout integration (iframe hosted on
iglobalstores.com) can now track GA4 analytics events across the full checkout funnel. Zonos Checkout automatically relays analytics events from the iframe to the parent page using a lightweight relay script, so events appear in your GA4 property as if they originated from your own site.