Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Click IDs lost after consent accepted: how to find and fix it

TRK-324Medium impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

A click ID is a parameter an ad platform adds to your link when someone clicks an ad. Google Ads adds gclid, Meta adds fbclid, Microsoft adds msclkid, TikTok adds ttclid. Your tags read it and store it in a first-party cookie (for example _gcl_aw for Google Ads or _fbc for Meta), so a later lead or sale can be matched to the ad click.

Why it costs you leads or sales

Where the click ID disappears
  1. Ad clickURL has ?gclid=abc
  2. Landing pageBanner shown, no choice yet
  3. Visitor clicks to page 2gclid no longer in URL
  4. Visitor accepts cookiesTags look for gclid, find nothing
  5. Lead or purchaseSent without click ID

The ID exists only on the first page. Consent comes later, so nothing is written.

Conversions matched to an ad clickExample numbers
Conversions matched to an ad click (example)Reported, ID lost after accept: 62 conversions; Reported, ID kept until accept: 94 conversions036726294Reported, ID lost aft…Reported, ID kept unt…conversions

Example: 100 real leads from ads. Numbers are illustrative only.

How to check if your site has it

Manual test in your browser
  1. Open a private window

    Clear cookies first so the banner appears again.

  2. Visit your landing page with a test click ID

    Add a fake value, for example https://yoursite.com/landing?gclid=TEST123&utm_source=google. Do not click the banner yet.

  3. Go to a second page

    Click a normal link, such as the contact page, then accept the banner.

  4. Look at the cookies

    In Chrome open DevTools > Application > Cookies. Look for _gcl_aw (it should contain TEST123) and _fbc if you tested fbclid.

  5. Repeat while accepting on the first page

    Compare. If the cookie exists only when you accept immediately, the ID is lost on the consent delay.

Consent arrives after the ID is gone

Tags wait for consent, and the click ID leaves with the first page.

How to fix it

Hold click IDs until consent is grantedjavascript
(function () {
  var keys = ['gclid', 'gbraid', 'wbraid', 'fbclid', 'msclkid', 'ttclid'];
  var params = new URLSearchParams(location.search);
  keys.forEach(function (k) {
    var v = params.get(k);
    if (v) sessionStorage.setItem('pending_' + k, v);
  });
})();

function writeClickIds() {
  var days = 90, exp = new Date(Date.now() + days * 864e5).toUTCString();
  var gclid = sessionStorage.getItem('pending_gclid');
  if (gclid) document.cookie = 'gclid=' + encodeURIComponent(gclid) + '; expires=' + exp + '; path=/; SameSite=Lax; Secure';
  var fbclid = sessionStorage.getItem('pending_fbclid');
  if (fbclid) {
    var fbc = 'fb.1.' + Date.now() + '.' + fbclid;
    document.cookie = '_fbc=' + fbc + '; expires=' + exp + '; path=/; SameSite=Lax; Secure';
  }
}
// Call writeClickIds() from your consent banner's 'accepted' callback.
Where to put it on your platform
  1. Capture on every page

    Create a Custom HTML tag with the first part of the snippet. Trigger: Consent Initialization - All Pages, or Initialization - All Pages if your banner does not use consent signals. It stores the ID only in sessionStorage.

  2. Write on consent

    Create a second Custom HTML tag with writeClickIds(). Set its trigger to your banner's consent-granted event, and require ad_storage granted under Advanced Settings > Consent Settings.

  3. Preview

    Use Tag Assistant preview with ?gclid=TEST123, browse to a second page and accept. Confirm the tag fires after accept.

Try the consent pathInteractive
Click ID held until consent

Consent: blocked / denied

  • GA4no hit
  • Google Adsno hit
  • Meta Pixelno hit

Visitor accepts on page 2, the click ID is already gone, and the conversion is sent without it.

Toggle to compare what happens to the click ID after a visitor accepts.

How to confirm it's fixed

Confirmation checks
  • Land with ?gclid=TEST123, go to a second page, accept: _gcl_aw or your own cookie contains TEST123.
  • Land with ?fbclid=TEST456 and accept: _fbc ends with TEST456.
  • Land, then reject: no click ID cookie is written and pending values are cleared.
  • Submit a test lead after accepting: the conversion request in the Network tab includes the click ID.
  • Repeat on mobile Safari, where cookie limits are stricter.

How to prevent it happening again

Habits that keep it working
  • Re-run the landing, second page, accept test after any change to the banner, theme or tag setup.
  • Test with a new banner version before it goes live, since new vendors often change callback names.
  • Keep the consent-granted trigger documented in your tag container notes.
  • Compare ad platform conversions with CRM leads each month and investigate gaps.
  • Do not add redirects on landing pages that drop query strings (see related issues).

How FunnelGuard handles this

Questions people ask

Why is my gclid not saved after I accept cookies?

The gclid is only in the landing page URL. If the banner is accepted after the visitor has moved to another page, your tags no longer see it. Store it in session storage on landing and write the cookie when consent is granted.

Should click IDs be stored when a visitor rejects cookies?

No. If the visitor denies advertising consent, not writing the click ID cookie is expected and correct. Clear any pending values and only store them if consent is given.

How do I check if the _gcl_aw cookie is set after consent?

Open your page with ?gclid=TEST123 in a private window, go to a second page, accept the banner, then open DevTools > Application > Cookies. The _gcl_aw cookie should contain your test value.

Does Google Consent Mode fix lost click IDs?

Not by itself. Consent Mode controls which signals tags may use, and Google tags can keep the click ID while consent is pending in some setups. You still need to confirm with a test that the ID survives navigation and ends up in the cookie after accept.

Why does fbclid not create the _fbc cookie after consent?

The Meta pixel builds _fbc from fbclid in the URL when it loads with consent. If the pixel loads after the URL has changed, there is nothing to read. Keep fbclid in session storage and build the cookie on consent.

Can FunnelGuard detect click IDs lost after consent?

Only partly. FunnelGuard checks that your tracking hits fire along the journey and alerts you when a step or tag breaks, but it does not inspect visitors' consent timing or cookie contents, so test that path by hand.

Is storing click IDs in session storage allowed before consent?

That depends on your local rules and how you describe it in your privacy policy. Ask your legal adviser. If in doubt, use a stricter approach such as asking for consent before the visitor can browse past the landing page.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

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.