Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Headless checkout losing tracking from the main site: fix

TRK-392High impactPartlyBy FunnelGuardPublished Updated
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.

Where attribution is lost
  1. Ad clickLanding URL has gclid and UTMs
  2. Headless storefrontTags see the campaign correctly
  3. Link to checkoutNo _gl parameter added
  4. Checkout domainNew session, source is your own site
  5. 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

Where purchases are creditedExample numbers
Where purchases are credited (example)Paid (broken): 12 % of purchases; Paid (fixed): 41 % of purchases; Direct/referral (broken): 70 % of purchases; Direct/referral (fixed): 24 % of purchases0275412417024Paid (broken)Paid (fixed)Direct/referral (brok…Direct/referral (fixe…% of purchases

Example: the same 100 purchases, reported before and after cross-domain linking is fixed.

How to check if your site has it

Check the hand-off by hand
  1. Open the storefront with test parameters

    Visit your site with ?utm_source=test&utm_medium=cpc&utm_campaign=xdomain in a private window.

  2. 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.

  3. Check the checkout URL

    If the address on the checkout domain has no _gl parameter, the linker is not working for that hop.

  4. Use GA4 DebugView or Tag Assistant

    On the checkout page, check the first event. If page_location has no campaign details and the session starts again, the session was not carried over.

  5. 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

Fix cross-domain tracking by platform
  1. 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.

  2. Configure domains in the Google tag

    In the Google tag (GA4 configuration), under Configuration settings, add the parameter linker with the domains yourstore.com and checkout.yourstore.com. You can also set this in GA4 under Admin > Data streams > Configure tag settings > Configure your domains.

  3. Turn on auto link and form decoration if needed

    Set accept_incoming to true on the checkout side. Use decorate_forms if the hand-off is a form submit.

  4. 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.

gtag.js linker config and manual decorationjavascript
// 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);
});
Cover the other platforms
  1. 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.

  2. 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.

  3. 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

What you should see

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
Confirmation checklist
  • Click through from a UTM-tagged landing page to checkout in a private window
  • The _gl parameter 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

Prevention habits
  • 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

How the problem usually unfolds
  1. Launch day

    Headless storefront goes live with checkout on a separate domain.

  2. Week 1

    Direct and referral traffic rise while paid conversions fall.

  3. Week 3

    Campaigns get paused because they look unprofitable.

  4. 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.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

How: cross_domain.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.