On this page
What this issue is
A headless site separates the front end (the pages visitors browse, often built with Next.js, Hydrogen or similar) from the commerce back end. The checkout is frequently hosted elsewhere, for example checkout.yourstore.com, a different domain such as yourstore.myshopify.com, or a payment provider's hosted page.
- Ad clickLanding URL has gclid and UTMs
- Headless storefrontTags see the campaign correctly
- Link to checkoutNo _gl parameter added
- Checkout domainNew session, source is your own site
- Purchase eventCredited to direct or referral
The visitor arrives from an ad, but the checkout domain starts a new session.
Why it costs you leads or sales
Example: the same 100 purchases, reported before and after cross-domain linking is fixed.
How to check if your site has it
Open the storefront with test parameters
Visit your site with
?utm_source=test&utm_medium=cpc&utm_campaign=xdomainin a private window.Hover the checkout link or button
Look at the destination URL. On a correctly linked setup it contains
_gl=followed by a long value. If the link is created by JavaScript, click it and read the address bar on the checkout page.Check the checkout URL
If the address on the checkout domain has no
_glparameter, the linker is not working for that hop.Use GA4 DebugView or Tag Assistant
On the checkout page, check the first event. If
page_locationhas no campaign details and the session starts again, the session was not carried over.Look for self-referrals in reports
In GA4, open Reports > Acquisition > Traffic acquisition and filter for your own storefront or checkout domain as a referral source.
How to fix it
Load the same container on both domains
Add your GTM container to the storefront and to the checkout so both send to the same GA4 property.
Configure domains in the Google tag
In the Google tag (GA4 configuration), under Configuration settings, add the parameter
linkerwith the domainsyourstore.comandcheckout.yourstore.com. You can also set this in GA4 under Admin > Data streams > Configure tag settings > Configure your domains.Turn on auto link and form decoration if needed
Set
accept_incomingto true on the checkout side. Usedecorate_formsif the hand-off is a form submit.Remove checkout from the referral exclusion list mistakes
In GA4 Admin > Data streams > Configure tag settings > List unwanted referrals, add the checkout domain as a safety net. This does not replace linking.
Add the linker config to gtag.js
Use the snippet below on both domains, with your own measurement ID and domains.
Decorate JavaScript-built URLs
If your app builds the checkout URL in code or uses
window.location, the automatic linker will not touch it. Use thegetcall shown below to read the linker value and append it.Preserve the query string on redirects
Make sure your server or edge redirect keeps
_gl,gclidand UTM parameters when sending the visitor to checkout.
Check which domain checkout uses
In Shopify admin, open Settings > Domains. Your primary domain and checkout domain should match your storefront wherever possible.
Use Shopify's built-in tracking for checkout
Checkout runs in a controlled environment. Add pixels through Settings > Customer events rather than expecting your storefront code to run there.
Add domains to cross-domain settings
Add both your storefront and the Shopify checkout domain in GA4 under Configure your domains.
Use a tag plugin or GTM
If WordPress is your front end and checkout is hosted elsewhere, add the Google tag or GTM through your tag plugin on the WordPress side.
Set cross-domain in GA4
In GA4 Admin > Data streams > Configure tag settings > Configure your domains, add the WordPress domain and the checkout domain.
Check the checkout link
Confirm the button URL gets
_glwhen clicked. Some page builders rewrite links after load.
// On both domains, in the Google tag config
gtag('config', 'G-XXXXXXXXXX', {
linker: {
domains: ['yourstore.com', 'checkout.yourstore.com'],
accept_incoming: true
}
});
// When your app builds the checkout URL itself
gtag('get', 'G-XXXXXXXXXX', 'linker', function (linker) {
// Read the linker value your app should append to the checkout URL
console.log(linker);
});Google Ads
Turn on auto-tagging and use the Google tag on both domains so the click ID is stored. The linker also passes the ad click identifiers between listed domains.
Meta, TikTok and others
Install each pixel on the checkout domain too, and send the purchase event from there. These tools do not use
_gl, so check their own documentation for any first-party click ID handling.Keep a consistent consent setup
If the checkout shows a different cookie banner, the visitor's consent choice may not carry over. Use the same consent tool on both domains where you can.
How to confirm it's fixed
Broken
- Checkout URL has no _gl parameter
- New session starts on the checkout domain
- Purchases show as direct or as your own site
Fixed
- Checkout URL contains _gl after the click
- Same session continues across domains
- Purchases keep the original source and campaign
- Click through from a UTM-tagged landing page to checkout in a private window
- The
_glparameter appears on the checkout URL - GA4 DebugView shows one continuous session across both domains
- The purchase event carries the campaign from the landing page
- Your checkout domain no longer appears in the referral report after a day or two
- Ad platform conversion counts recover over the following days
How to prevent it happening again
- Keep a list of every domain in the buying journey, including payment and booking pages
- Re-test the hand-off after any change to the checkout, domain or redirect rules
- Treat new checkout providers or apps as a tracking change and test them before launch
- Document where each tag runs and who owns it
- Run a scheduled test purchase journey, not only a one-off check at launch
How FunnelGuard handles this
Launch day
Headless storefront goes live with checkout on a separate domain.
Week 1
Direct and referral traffic rise while paid conversions fall.
Week 3
Campaigns get paused because they look unprofitable.
After the fix
Linking is configured and sources return to the purchase report.
Questions people ask
Why is my headless checkout showing as a referral in GA4?
The checkout is on a different domain, so GA4 treats the visitor as new and records your storefront as the referrer. Add both domains under Configure your domains and make sure the link to checkout carries the _gl parameter.
How do I set up cross-domain tracking for a headless Shopify store?
Load the same Google tag on the storefront and, where allowed, on checkout via Customer events. In GA4, add both domains under Admin > Data streams > Configure tag settings > Configure your domains, then confirm _gl appears on the checkout URL.
What is the _gl parameter?
It is the linker parameter Google tags add to links between domains you list. It carries the client and session identifiers so the second domain can continue the same visit instead of starting a new one.
Why does the _gl parameter not appear on my checkout link?
Common causes are the checkout domain missing from the domain list, a link built in JavaScript after the tag decorates links, or a redirect that strips the query string. Test the final URL after any redirects.
Does adding my checkout to unwanted referrals fix attribution?
No. It only stops the checkout domain being labelled as a referral. The original source is still lost unless cross-domain linking passes it on.
Will fixing cross-domain tracking restore past data?
No. Reports for earlier purchases stay as recorded. The fix improves attribution from the time it is live.
Can FunnelGuard detect cross-domain tracking problems?
Partly. It checks the hop between your site and the next domain on a schedule and alerts you if tracking does not carry across. It does not read your analytics reports or cover every way a checkout link can be built, so manual checks still matter.
Related issues
- TRK-401Iframe-embedded checkout tracking not reaching parentFix guide
- TRK-393Shopify checkout extensibility removed checkout.liquid scriptsFix guide
- TRK-394Shopify Customer Events (web pixel) sandbox missing eventsFix guide
- TRK-395Shopify thank-you 'additional scripts' deprecated, purchase lostFix guide
- TRK-389SPA route change sends no page_viewFix guide
- TRK-400Tracking only in site header, funnel pages use blank templateFix guide