How to Track Marketing Click IDs & Attribution Cookies Across Meta, Google, TikTok & Affiliates

| Incisive Ranking
Every major advertising network—from Meta CAPI and Google Ads OCI to TikTok Events API, Microsoft UET, and affiliate networks like Awin and Rakuten—relies on cryptographic Click IDs and browser fingerprint cookies to credit conversions. When a user clicks an ad, unique query parameters (such as 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.

+34%
Recovered Conversion Match

Attributed orders previously labeled as "Direct / None" due to missing Click ID linkage.

9.4 / 10
Server CAPI Match Quality

Maximized Meta & TikTok Event Match Quality by passing persistent _fbc, _fbp, and ttclid.

90–180 Days
Cookie Retention Window

Achieved by anchoring attribution cookies via Server-Side GTM HttpOnly headers over raw JavaScript.

⚡ Multi-Channel Click ID Ingestion & Dispatch Pipeline
How Incoming Marketing Query Parameters Are Preserved in First-Party Cookies & Forwarded to Conversion APIs
1. INCOMING CLICKS ?fbclid=IwAR2... ?gclid=Cj0KCQ... ?ttclid=E.C.P... ?msclkid=7f4a... ?awc= / ?ranMID= 2. HARVESTER & STORAGEUniversal Cookie Vault Web GTM / Client-Side JS _fbc = fb.1.{ts}.{fbclid} _gcl_aw / FPGCLAW _ttp / _uetvid / _scid Hidden CRM Form Fields 3. SERVER sGTM Custom Subdomain ss.yourdomain.com HttpOnly Header Set ITP 7-Day Bypass Conversion Dispatch Meta CAPI Google Ads OCI TikTok Events Affiliates / CRM

Attribution Retention Over 30 Days: Raw Pixel vs. First-Party Vault

Safari ITP Day-14 Attribution Survival Standard JavaScript Pixels (8%) vs First-Party sGTM Vault (96%)
Meta Event Match Quality (EMQ) With Click IDs Without _fbc / _fbp (4.8 / 10) vs With _fbc + _fbp Vault (9.4 / 10)
Affiliate Conversion Attribution (Awin / Rakuten) Standard Cookie (62% Tracked) vs Multi-Storage Harvester (99% Tracked)
Auditing Your Attribution Health: If your ad campaigns show unexplained attribution drops or your Server CAPI event match quality is below 8.0, your cookie harvester is leaking data. Request an audit through our Free Tracking Audit Form.

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 / NetworkURL Click ParameterGenerated 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 Adsttclidttclid, _ttpttclid stores raw click string. _ttp stores unique TikTok browser cookie ID for Events API.
Google Ads & DV360gclid, 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 Advertisingmsclkid_uetmsclkid, uet_msclkid, _uetvid, uet_vid_uetmsclkid stores Microsoft Click ID. _uetvid stores persistent UET Visitor ID for CAPI matching.
LinkedIn Adsli_fat_idli_fat_idStores LinkedIn First-Party Ad Tracking ID (starts with fpt_...) for Conversions API.
Pinterest Adsepik_epikStores Pinterest Enhanced Match Click Identifier used by the Pinterest Conversion API.
Snapchat Adssc_click_id_scclid, _scid_scclid stores Snap Click ID. _scid stores unique device fingerprint for Snap CAPI.
Native (Taboola & Outbrain)tblci, dicbidtaboola_cid, outbrain_cidStores click identifiers passed through native content recommendation ad widgets.
Affiliate: Awinawcawin_awc, awin_sn_awc, awin_sourceStores Awin Click Reference (AWC) and source network tracking keys.
Affiliate: RakutenranMID, ranEAID, ranSiteIDrakuten_site_id, rakuten_ran_mid, rakuten_ran_eaidMulti-parameter attribution cookies for Rakuten Advertising publisher payouts.
Affiliate: Webgainswgcidwg_cidStores Webgains transaction tracking click reference.
Retention: Klaviyo & Postscript_kx, ps_idstape_klaviyo_kx, stape_klaviyo_email, ps_idAttribution keys identifying subscribers across automated SMS & Email revenue flows.
AI Search (OpenAI / ChatGPT)Referral query tokens__oppref, __obrefCustom 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:

Universal Multi-Channel Attribution Harvester Script
(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.

The Enterprise Solution

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_aw cookies, 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:

  1. 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">
  2. Populate from Harvested Cookies: Use GTM or JavaScript to read the first-party cookie values (e.g., read _gcl_aw or _fbc) and populate the hidden form inputs upon form load.
  3. Store in CRM Lead Record: When the lead submits, the CRM permanently records the exact Click ID alongside the contact's email address.
  4. Automate Offline Uploads via n8n or Make: When the deal stage transitions to "Closed Won", an automated webhook dispatches the stored gclid or fbclid to 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 _fbc cookie 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 from blog.yourstore.com to checkout.yourstore.com.
  • ✔
    Confirm Enhanced Conversion Matching (FPGCLAW): If using Server-Side GTM, ensure the Google Ads Conversion Linker tag creates FPGCLAW cookies on your server endpoint.
  • ✔
    Check TikTok _ttp and ttclid Sync: Verify in the TikTok Pixel Helper and Events Manager that server-side Purchase events carry both the ttclid parameter and _ttp cookie.
  • ✔
    Inspect Hidden Form Injections on Mobile: Submit mobile test leads across Safari and Chrome to verify that hidden gclid and msclkid fields populate accurately inside your CRM.
  • ✔
    Validate Affiliate Link Parameters: For Awin and Rakuten networks, confirm that checkout confirmation tags extract awin_awc and rakuten_ran_mid to prevent affiliate payout discrepancies.
  • ✔
    Enforce SameSite=Lax and Secure Flags: Verify that all attribution cookies declare SameSite=Lax and Secure to prevent modern browser blocking.
  • ✔
    Consent Mode v2 Alignment: Ensure that advertising cookies (_fbc, _gcl_aw) are only read and transmitted when ad_storage='granted' under GDPR/DMA mandates.

Stop Losing 30% of Your Ad Attribution to Expired Cookies

Incisive Ranking builds resilient, enterprise-grade attribution architectures—combining Server-Side GTM, first-party cookie keepers, and CRM conversion pipelines to track every dollar across all channels.

Claim Your Free Tracking Audit

I am also available here!

| Incisive Ranking
| Incisive Ranking
| Incisive Ranking
| Incisive Ranking

Follow Us:

About Us

We are experts in Tags and Tracking Services. With experience in eCommerce and Custom Conversion tracking, Server Side Tagging, and Data tracking to help you get the advantage of ACCURATE data for better decision making. With more than 6 years of experience, We have already delivered more than 500 projects.