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
- Ad clickURL has ?gclid=abc
- Landing pageBanner shown, no choice yet
- Visitor clicks to page 2gclid no longer in URL
- Visitor accepts cookiesTags look for gclid, find nothing
- Lead or purchaseSent without click ID
The ID exists only on the first page. Consent comes later, so nothing is written.
Example: 100 real leads from ads. Numbers are illustrative only.
How to check if your site has it
Open a private window
Clear cookies first so the banner appears again.
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.
Go to a second page
Click a normal link, such as the contact page, then accept the banner.
Look at the cookies
In Chrome open DevTools > Application > Cookies. Look for
_gcl_aw(it should contain TEST123) and_fbcif you tested fbclid.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.
Tags wait for consent, and the click ID leaves with the first page.
How to fix it
(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.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.
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.
Preview
Use Tag Assistant preview with ?gclid=TEST123, browse to a second page and accept. Confirm the tag fires after accept.
Use a consent plugin with Google Consent Mode
Check your banner plugin's settings for Google Consent Mode support and that Google tags are loaded through it. Menu names differ by plugin.
Add the snippet
Add the code through a header-scripts plugin or your child theme, and call writeClickIds() from the plugin's accept event. Avoid editing the parent theme directly.
Clear caches
Purge page cache and any CDN so the new script is served.
Use Customer Privacy API
In Settings > Customer events, add a custom pixel or use your consent app. Shopify exposes consent state through its Customer Privacy API, so run writeClickIds() once marketing consent is true.
Capture on landing
Add the first part of the snippet to theme.liquid before the closing head tag so it runs on every page.
Add the capture code
Go to Site settings > Custom code > Head code and paste the first part of the snippet.
Hook your banner
Call writeClickIds() from the accept callback of your consent tool, or load it in the tool's marketing-category script area.
Publish
Code only runs on the published site, not in the Designer.
Load capture early
Put the capture function in a script that loads on every page, before any banner logic.
Call on accept
Run writeClickIds() in the callback your consent management platform provides for granted marketing or advertising 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
- Land with ?gclid=TEST123, go to a second page, accept:
_gcl_awor your own cookie contains TEST123. - Land with ?fbclid=TEST456 and accept:
_fbcends 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
- 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.
Related issues
- TRK-311UTMs lost on redirect (http->https, www, trailing slash)Fix guide
- TRK-312UTMs lost when moving from landing page to form pageFix guide
- TRK-322fbclid/gclid trigger 404 or WAF block on landing pageFix guide
- TRK-325Click IDs expire before conversion (cookie lifetime cut by ITP)Fix guide
- TRK-334Server redirects drop query string (301 to /)Fix guide
- TRK-335Language/geo redirect drops click IDsFix guide