fbclid, gclid, or ttclid) land on your URL. But if your tracking architecture fails to immediately harvest and store these values in resilient first-party cookies, Apple's Safari ITP, privacy browsers, and multi-page user journeys wipe them clean in minutes.Losing these identifiers means your Server-Side APIs (Conversions API) receive anonymous conversion hits with poor Match Quality (EMQ), Smart Bidding models starve for accurate attribution signals, and affiliate partner sales go untracked. In this master technical guide, we break down the definitive multi-channel attribution cookie architecture: how to harvest, normalize, persist, and dispatch Click IDs across every major marketing platform.
Attributed orders previously labeled as "Direct / None" due to missing Click ID linkage.
Maximized Meta & TikTok Event Match Quality by passing persistent _fbc, _fbp, and ttclid.
Achieved by anchoring attribution cookies via Server-Side GTM HttpOnly headers over raw JavaScript.
Attribution Retention Over 30 Days: Raw Pixel vs. First-Party Vault
1. The Multi-Channel Attribution Cookie Master Matrix
Different advertising and affiliate networks deploy unique naming conventions and formatting standards for their click parameters and browser identity cookies. To establish a reliable tracking pipeline, you must map every network’s URL parameter to its corresponding cookie structure:
| Platform / Network | URL Click Parameter | Generated Cookie Name(s) | Standard Cookie Format & Role |
|---|---|---|---|
| Meta (Facebook / IG) | fbclid | _fbc, _fbp, _gtmeec | _fbc = fb.1.{epoch_ts}.{fbclid} (Click ID). _fbp = Browser ID. _gtmeec = GTM Enhanced E-commerce cache. |
| TikTok Ads | ttclid | ttclid, _ttp | ttclid stores raw click string. _ttp stores unique TikTok browser cookie ID for Events API. |
| Google Ads & DV360 | gclid, gbraid, wbraid | _gcl_aw, FPGCLAW, _gcl_gb, _gcl_dc | _gcl_aw / FPGCLAW (Web Ads). _gcl_gb (App iOS). _gcl_dc (Display & Video 360). _dm_session_attributes. |
| Microsoft Advertising | msclkid | _uetmsclkid, uet_msclkid, _uetvid, uet_vid | _uetmsclkid stores Microsoft Click ID. _uetvid stores persistent UET Visitor ID for CAPI matching. |
| LinkedIn Ads | li_fat_id | li_fat_id | Stores LinkedIn First-Party Ad Tracking ID (starts with fpt_...) for Conversions API. |
| Pinterest Ads | epik | _epik | Stores Pinterest Enhanced Match Click Identifier used by the Pinterest Conversion API. |
| Snapchat Ads | sc_click_id | _scclid, _scid | _scclid stores Snap Click ID. _scid stores unique device fingerprint for Snap CAPI. |
| Native (Taboola & Outbrain) | tblci, dicbid | taboola_cid, outbrain_cid | Stores click identifiers passed through native content recommendation ad widgets. |
| Affiliate: Awin | awc | awin_awc, awin_sn_awc, awin_source | Stores Awin Click Reference (AWC) and source network tracking keys. |
| Affiliate: Rakuten | ranMID, ranEAID, ranSiteID | rakuten_site_id, rakuten_ran_mid, rakuten_ran_eaid | Multi-parameter attribution cookies for Rakuten Advertising publisher payouts. |
| Affiliate: Webgains | wgcid | wg_cid | Stores Webgains transaction tracking click reference. |
| Retention: Klaviyo & Postscript | _kx, ps_id | stape_klaviyo_kx, stape_klaviyo_email, ps_id | Attribution keys identifying subscribers across automated SMS & Email revenue flows. |
| AI Search (OpenAI / ChatGPT) | Referral query tokens | __oppref, __obref | Custom attribution markers tracking conversational AI citation sessions and referral hops. |
2. Production JavaScript: The Universal Click ID Harvester
When users navigate from your ad landing page to other pages or subdomains, raw URL query parameters disappear. Deploy this universal harvester script via Google Tag Manager (Trigger: Consent Initialization or Initialization) to capture query parameters, construct standards-compliant cookies (including Meta's _fbc specification), and sync them to first-party storage:
(function() {
// 1. Helper: Read query parameters safely
function getParam(name) {
var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
return match ? decodeURIComponent(match[1].replace(/\+/g, ' ')) : null;
}
// 2. Helper: Write First-Party Cookie (90-Day Lifespan)
function setCookie(name, value, days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toUTCString();
}
// Set domain to top-level domain for cross-subdomain availability
var domain = window.location.hostname.replace(/^www\./i, '');
document.cookie = name + "=" + (value || "") + expires + "; path=/; domain=." + domain + "; SameSite=Lax; Secure";
}
// 3. Capture Meta Click ID and format _fbc
var fbclid = getParam('fbclid');
if (fbclid) {
var fbcValue = 'fb.1.' + (+new Date()) + '.' + fbclid;
setCookie('_fbc', fbcValue, 90);
}
// 4. Capture Google Click IDs (Web, iOS GBRAID/WBRAID)
var gclid = getParam('gclid');
if (gclid) setCookie('_gcl_aw', gclid, 90);
var gbraid = getParam('gbraid');
if (gbraid) setCookie('_gcl_gb', gbraid, 90);
var wbraid = getParam('wbraid');
if (wbraid) setCookie('_gcl_dc', wbraid, 90);
// 5. Capture TikTok, Microsoft, LinkedIn, Pinterest, Snapchat
var ttclid = getParam('ttclid');
if (ttclid) setCookie('ttclid', ttclid, 90);
var msclkid = getParam('msclkid');
if (msclkid) {
setCookie('uet_msclkid', msclkid, 90);
setCookie('_uetmsclkid', msclkid, 90);
}
var liFatId = getParam('li_fat_id');
if (liFatId) setCookie('li_fat_id', liFatId, 90);
var epik = getParam('epik');
if (epik) setCookie('_epik', epik, 90);
var scClickId = getParam('sc_click_id');
if (scClickId) setCookie('_scclid', scClickId, 90);
// 6. Capture Affiliate Click IDs (Awin, Rakuten, Webgains, Taboola)
var awc = getParam('awc');
if (awc) setCookie('awin_awc', awc, 90);
var ranMid = getParam('ranMID');
if (ranMid) setCookie('rakuten_ran_mid', ranMid, 90);
var ranEaid = getParam('ranEAID');
if (ranEaid) setCookie('rakuten_ran_eaid', ranEaid, 90);
var wgcid = getParam('wgcid');
if (wgcid) setCookie('wg_cid', wgcid, 90);
var tblci = getParam('tblci');
if (tblci) setCookie('taboola_cid', tblci, 90);
// 7. Push unified attribution object to GTM DataLayer
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'attribution_cookies_ready',
attribution: {
meta_fbc: fbclid ? ('fb.1.' + (+new Date()) + '.' + fbclid) : null,
google_gclid: gclid,
tiktok_ttclid: ttclid,
ms_clkid: msclkid,
linkedin_fat_id: liFatId
}
});
})();3. How to Protect Attribution Cookies from Safari ITP Truncation
Under Apple’s WebKit Intelligent Tracking Prevention (ITP), any cookie set via client-side JavaScript (document.cookie) by a user arriving from a classified tracker URL (like Facebook or Google Ad links) is forcefully capped at a 7-day or 24-hour expiration.
If your customer browses your catalog today and completes their purchase 9 days later, client-side cookies have expired, breaking your ad attribution completely.
Server-Side GTM (sGTM) HttpOnly Cookie Anchoring
When your tracking routes through a Server-Side GTM container hosted on your own subdomain (e.g., ss.yourdomain.com), the server issues cookies using the Set-Cookie HTTP response header.
- ITP Immunity: Safari recognizes HTTP response cookies set by the primary domain as genuine server-side cookies, preserving their full 90-to-180-day lifespan.
- The Stape / Custom Cookie Keeper: Specialized sGTM templates (like Stape's Cookie Keeper) automatically intercept incoming
_fbp,_fbc,_ttp, and_gcl_awcookies, backing them up in server-side storage and restoring them if Safari purges client storage.
4. Passing Click IDs to CRM & Offline Conversion Tracking (OCT)
For high-ticket B2B, real estate, and lead generation companies, the sale doesn't happen in the web browser. It closes weeks later inside a CRM (HubSpot, Salesforce, Zoho).
To connect offline revenue back to ad platforms:
- Create Hidden Form Fields: Add hidden inputs on all website lead forms:
<input type="hidden" name="gclid" id="field_gclid"><input type="hidden" name="fbclid" id="field_fbclid"><input type="hidden" name="ttclid" id="field_ttclid"> - Populate from Harvested Cookies: Use GTM or JavaScript to read the first-party cookie values (e.g., read
_gcl_awor_fbc) and populate the hidden form inputs upon form load. - Store in CRM Lead Record: When the lead submits, the CRM permanently records the exact Click ID alongside the contact's email address.
- Automate Offline Uploads via n8n or Make: When the deal stage transitions to "Closed Won", an automated webhook dispatches the stored
gclidorfbclidto Google Ads OCI and Meta CAPI, unlocking Target ROAS (tROAS) bidding.
5. 8-Point Multi-Channel Attribution Audit Checklist
Before scaling your paid ad spend across channels, verify that your Click ID and cookie harvesting engine passes these technical benchmarks:
-
Verify 'fb.1.' Format for _fbc: In DevTools Application > Cookies, confirm that your
_fbccookie strictly follows the official Meta specification (fb.1.{epoch_timestamp}.{fbclid}). -
Test Cross-Subdomain Cookie Availability: Ensure cookies are set with a leading dot on your root domain (e.g.,
domain=.yourstore.com) so tracking persists fromblog.yourstore.comtocheckout.yourstore.com. -
Confirm Enhanced Conversion Matching (FPGCLAW): If using Server-Side GTM, ensure the Google Ads Conversion Linker tag creates
FPGCLAWcookies on your server endpoint. -
Check TikTok _ttp and ttclid Sync: Verify in the TikTok Pixel Helper and Events Manager that server-side
Purchaseevents carry both thettclidparameter and_ttpcookie. -
Inspect Hidden Form Injections on Mobile: Submit mobile test leads across Safari and Chrome to verify that hidden
gclidandmsclkidfields populate accurately inside your CRM. -
Validate Affiliate Link Parameters: For Awin and Rakuten networks, confirm that checkout confirmation tags extract
awin_awcandrakuten_ran_midto prevent affiliate payout discrepancies. -
Enforce SameSite=Lax and Secure Flags: Verify that all attribution cookies declare
SameSite=LaxandSecureto prevent modern browser blocking. -
Consent Mode v2 Alignment: Ensure that advertising cookies (
_fbc,_gcl_aw) are only read and transmitted whenad_storage='granted'under GDPR/DMA mandates.





