Technical Deep-Dive · 11 min read

Click ID Server-Side Recovery: gclid, fbclid, ttclid for CAPI

gclid (Google), fbclid (Meta), ttclid (TikTok), msclkid (Microsoft) and other click IDs link an ad click to a conversion. This playbook shows the recovery pattern: capture click IDs at landing, keep them in first-party storage on your domain, join orders back to visits by hashed email, and send them to Meta and TikTok server-side. Forwarding to Google Ads is not available yet.

13
Click ID formats captured
Google, Meta, TikTok, Microsoft and more
90 days
Click ID storage
First-party, on your domain
Order ID
Dedup key
Shared by browser and server events

What is a click ID, and why does it carry the attribution

A click ID is a short opaque string an ad network attaches as a query parameter to the landing URL when a user clicks one of its ads. The network minted the string at click time on its own servers, so it is the only identifier guaranteed to map the downstream conversion back to the specific ad click that drove it. Google Ads attaches gclid; Meta attaches fbclid; TikTok attaches ttclid; Microsoft Ads attaches msclkid; and so on for each network. The format and length differ per network, but the function is identical — a one-to-one key between a click event in the ad network's logs and a conversion event in your store.

Click IDs matter for two reasons that compound. First, they are the only identifier the ad network itself trusts when you send a conversion back via CAPI or Enhanced Conversions; pixel cookies and IP-based fingerprints are weaker match signals because they can be spoofed or shared. Second, they are the only identifier that survives the parts of the modern web that break other signals — third-party cookie deprecation, Safari ITP's seven-day localStorage cap, and cross-device journeys where the user clicks on mobile and converts on desktop. Without click IDs, the ad network's bidding algorithm receives degraded conversion signal and over-allocates to lower-intent audiences.

Without click IDs flowing back to the ad network, the typical match rate for a DTC store post-iOS 17 falls to roughly sixty percent. With click IDs captured at landing and forwarded via server-side CAPI, the match rate stays at ninety-five percent or higher. The fifteen to thirty-five point gap is the difference between a campaign that the algorithm correctly attributes and a campaign that the algorithm under-credits, leading to under-spend on what is actually your highest-LTV channel.

Why click IDs are the only stable cross-device, cross-cookie attribution signal

Every other signal you might attempt to attribute on has been degraded by browser and OS-level privacy changes over the past three years. Third-party cookies are deprecated on Safari (since 2020) and Brave (since launch), are blocked by default on Firefox, and are scheduled for full deprecation on Chrome under the Privacy Sandbox roadmap. Device fingerprinting is restricted by Safari ITP's storage partitioning and by Brave's randomization. IP-based geolocation is increasingly proxied through iCloud Private Relay (default-on for iOS 15+ Safari) and standard mobile carrier NAT, which makes IP a coarse signal at best.

Click IDs are not affected by any of these mechanisms because they live in the URL itself, not in browser storage. When a user clicks an ad, the network appends the click ID to the destination URL as a query string, and the user's browser passes it to your server in the GET request. The click ID exists in the request line itself, before the browser has executed any JavaScript, before any cookie has been read or set, before any fingerprint can be computed. That earliness is what makes it stable.

The one threat to click ID stability is iOS 17 Link Tracking Protection, which strips known click identifiers from URLs opened in Mail, Messages, and Private Browsing Safari before the destination page loads. Apple maintains the strip-list internally and updates it with each iOS minor release. The mitigation pattern is documented in the iOS 17 attribution recovery playbook — capture click IDs via the network's pixel SDK at the ad-network side (where Apple cannot strip), forward via CAPI, and on the destination side use a first-party redirect that survives ATP.

Cross-link: iOS 17 Attribution Recovery for the ATP-specific recovery pattern. This article documents the click-ID capture and CAPI-forwarding layer; the iOS 17 article documents the upstream recovery when Apple strips the ID before it reaches the destination.

The 13 click ID formats Admaxxer captures

The list of click identifiers a modern DTC store needs to capture is longer than "fbclid and gclid". Admaxxer's first-party pixel captures the thirteen formats below by default and keeps each captured value in first-party storage on your domain for 90 days.

Click ID parameterNetwork / Surface
gclidGoogle Ads
gbraidGoogle Ads (iOS app-to-web)
wbraidGoogle Ads (iOS web-to-app)
fbclidMeta (Facebook + Instagram)
ttclidTikTok Ads
msclkidMicrosoft Ads
scidSnapchat Ads
rdt_cidReddit Ads
epikPinterest Ads
li_fat_idLinkedIn Ads
twclidX (Twitter) Ads
_kxKlaviyo email links
ko_click_idAdditional click ID, stored as received

The capture surface is the same for all thirteen — a single pass over the URL query parameters at landing, writing every recognized key to the first-party store. Every one is kept for attribution in Admaxxer. Server-side forwarding is narrower: fbclid builds the fbc field for Meta CAPI and ttclid goes to the TikTok Events API, for the ad accounts you connect and turn server-side sending on for. Forwarding gclid to Google Ads is not available yet.

Why localStorage is not enough — three failure modes

The naive implementation of click ID capture is to read the URL query string in JavaScript at landing, parse out fbclid and gclid, and call window.localStorage.setItem. This works in a one-page-load demo and fails in production for three independent reasons that compound.

  • Safari ITP caps localStorage to a 7-day TTL when the script that wrote it is loaded as a third-party. The cookie API has the same restriction, but localStorage is hit harder because Safari treats it as ephemeral storage from third-party origins. A user who clicked an ad on day 1 and returns to convert on day 8 has lost the click ID entirely if it was stored on a third-party script's storage.
  • iOS 17 Link Tracking Protection strips known click identifiers from URLs opened in Mail, Messages, and Private Browsing Safari before any JavaScript runs. The JavaScript that would have read the URL never sees the parameter — the OS removed it during URL resolution. localStorage capture only works after the JS has executed, which is too late.
  • Cross-device journeys are invisible to localStorage by design. localStorage is per-device, per-browser, per-profile. A user who clicks an ad on their iPhone in the morning and converts on their desktop browser in the evening has two separate localStorage stores. The click ID captured on the iPhone is irrelevant to the desktop conversion event.

A server-set first-party cookie (described below) addresses failure mode one. Joining the order back to the visitor by hashed email (also below) addresses failure mode three. iOS 17 link stripping (failure mode two) is covered in its own playbook. Admaxxer's pixel does store click IDs in localStorage today — with an in-memory fallback — so it is subject to the Safari limit described above.

The server-side session mirror — joining cross-device journeys by hashed email

First-party storage helps on the same device. It does not fix cross-device journeys: a click ID captured in iPhone Safari is not visible to the same person's desktop Chrome when they convert. To attribute that journey, the order has to be joined back to the earlier visit by something both devices share.

Admaxxer uses the customer's email for that join. The pixel gives each browser a random visitor ID in a first-party cookie. When a payment arrives (a store order or a billing payment) with an email, Admaxxer hashes the email and looks for a visitor who used the same hashed email before. If it finds one, the payment joins that visitor's journey — including the click IDs and first touch captured on the earlier device.

The email is stored and compared as a SHA-256 hash, not as cleartext, and the visitor ID is a random value that does not itself identify anyone. The join only works when the person used the same email on both devices, for example at checkout.

The Meta CAPI payload — fbc and fbp per the v25 spec

Meta's Conversions API expects click ID data in the user_data block of the event payload, in two specific fields: fbc (Facebook click identifier, derived from fbclid) and fbp (Facebook browser identifier, set by the Meta Pixel as a first-party cookie called _fbp). The fbc field is not the raw fbclid value — it is a composite string in the format "fb.1.{timestamp}.{fbclid}", where the timestamp is the Unix epoch milliseconds at click time. The fbp field is the literal _fbp cookie value if present, otherwise omitted.

Admaxxer's server-side forwarder sends the fbc and fbp values the pixel captured for that visitor (Meta's own cookies when present, otherwise an fbc built from the fbclid and its first-seen time), together with hashed email and phone, IP address and user agent. It posts a Purchase event to Meta's /events endpoint with event_id set to the order's ID from your store or payment provider (this is the deduplication key — see the next section).

An example of the shape of a server-side Purchase event (values are made up). Admaxxer sends one event per request, through a rate-capped job queue with automatic retries.

POST https://graph.facebook.com/v25.0/{PIXEL_ID}/events
Content-Type: application/json
Authorization: Bearer {CAPI_ACCESS_TOKEN}

{
  "data": [{
    "event_name": "Purchase",
    "event_time": 1747526400,
    "event_id": "shopify-order-5839124",
    "event_source_url": "https://store.example.com/checkout/thank-you",
    "action_source": "website",
    "user_data": {
      "em": ["e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"],
      "ph": ["7d793037a0760186574b0282f2f435e7d4e23d5f4f3b4f5f7b3e4e5d6c5a4b3a"],
      "fbc": "fb.1.1747526240000.IwAR2x3PqK8jM4nW9zY1aB7cD0eF6gH3iJ5kL7mN9oP1qR3sT5uV",
      "fbp": "fb.1.1747512000000.2098534201",
      "client_ip_address": "203.0.113.42",
      "client_user_agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 17_2 like Mac OS X) AppleWebKit/605.1.15"
    },
    "custom_data": {
      "currency": "USD",
      "value": 142.50,
      "content_ids": ["sku-blue-tee-m"],
      "content_type": "product",
      "num_items": 1
    }
  }]
}

Notice that email (em) and phone (ph) are SHA-256 hashed — Meta's spec requires hashing for personal identifiers in the user_data block. Admaxxer hashes them before the POST. The client_ip_address and client_user_agent are sent unhashed, as Meta's spec expects.

Google Enhanced Conversions — set up in Google Ads for now

Google's equivalent of Meta CAPI is Enhanced Conversions, which posts conversion events to the Google Ads API with the captured gclid plus hashed user identifiers (email, phone, address). The POST shape is different from Meta's — Google uses the googleads.googleapis.com Conversion Upload endpoint, and the payload structure follows the protobuf schema documented in the Google Ads API reference.

Admaxxer does not forward purchases to Google Ads yet. You may see a Google Ads panel in the connection drawer, but no conversions are sent to Google from it. Admaxxer still captures gclid, gbraid and wbraid for its own attribution. If you use Enhanced Conversions today, set it up in Google's own tools (the Google tag, Google Tag Manager or your store platform's Google integration), with your order ID as the transaction ID. The example below shows the upload shape for reference; Admaxxer does not send it.

POST https://googleads.googleapis.com/v17/customers/{CUSTOMER_ID}:uploadClickConversions
Authorization: Bearer {OAUTH_ACCESS_TOKEN}
developer-token: {DEVELOPER_TOKEN}
Content-Type: application/json

{
  "conversions": [{
    "gclid": "Cj0KCQjwzN-vBhCkARIsAEU8aXKvW1c9Q4M6f2I3jH5pL7rR9sT0uV3xY8zA1bB4cD6eF8gH",
    "conversion_action": "customers/1234567890/conversionActions/987654321",
    "conversion_date_time": "2026-05-18 14:00:00-07:00",
    "conversion_value": 142.50,
    "currency_code": "USD",
    "order_id": "shopify-order-5839124",
    "user_identifiers": [
      {
        "hashed_email": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
      },
      {
        "hashed_phone_number": "7d793037a0760186574b0282f2f435e7d4e23d5f4f3b4f5f7b3e4e5d6c5a4b3a"
      }
    ]
  }],
  "partial_failure": true
}

The order_id field is critical for deduplication — Google uses it to suppress duplicate conversion uploads if the same order is posted twice (a common occurrence when an order webhook fires both client-side via gtag and server-side via CAPI). The partial_failure flag instructs Google to accept the request even if a subset of conversions fail validation, returning per-conversion error details in the response. Check Google Ads' conversion diagnostics after setup and after any change.

Performance Max campaigns lean particularly hard on Enhanced Conversions — the algorithm's bidding logic uses the hashed user identifiers to model audience overlap and predict conversion likelihood. A Performance Max campaign running without Enhanced Conversions is the most common DTC under-performance pattern; the campaign appears to ROAS poorly because the bidding model has degraded signal.

Deduplication via event_id — the shared key that prevents double-counting

A single conversion event will fire to Meta twice — once from the client-side Meta Pixel running in the user's browser, and once from the server-side CAPI POST that Admaxxer sends. TikTok works the same way. Without an explicit deduplication key, the network would record the conversion as two separate events, inflating reported ROAS and corrupting the bidding model's training signal.

The deduplication key is the event_id field on both networks. Admaxxer sets event_id on the server event to the order's ID from your store or payment provider. Your browser-side Meta Pixel must send the same value as its event ID on the order confirmation page — check this in Meta Events Manager, because if the two IDs differ Meta counts the order twice. When they match, the two events arrive at Meta with identical event_ids; Meta's deduplication logic recognizes the pair as a single conversion and counts it once.

  • Pixel fires: event_id = "shopify-order-5839124", source = browser, with client-side cookies + browser fingerprint
  • CAPI fires: event_id = "shopify-order-5839124", source = server, with hashed email + fbc + fbp + IP + UA
  • Meta receives both, matches on event_id, counts the conversion exactly once, uses the union of the two payloads' user_data for match-rate scoring

The deduplication is asymmetric: Meta will count the conversion once even if one of the two events is missing, but the match rate scoring favors the pair. If only the pixel fires (CAPI is broken), Meta records the conversion but with weaker user_data; if only CAPI fires (pixel is blocked by an ad blocker), Meta records the conversion with stronger user_data because CAPI carries the hashed email. The dual-feed design therefore both prevents double-counting AND maximizes the per-conversion match rate.

Verifying capture — a test order and the tracking-health check

After the pixel is installed, verify capture with a real test order (refund it afterwards):

  • Click ID stored: open your store from a URL with a test click ID (for example ?gclid=test123), then look for an admaxxer_clickid: entry in your browser's developer tools.
  • Order attributed: place the order, then find it on Admaxxer's Sources & Attribution page on the right source.
  • Server events received: Meta Events Manager shows the Purchase from browser and server, deduplicated; TikTok Events Manager shows the same for TikTok if you send there.

Ongoing, the Tracking Health badge on Sources & Attribution compares, per channel, the conversions your pixel attributed with the conversions the ad platform reports. It shows healthy (within 10%), minor drift (10-30%), major drift (over 30%) or untracked. Usual causes of drift: an expired server-side access token, a consent banner blocking the pixel, a theme change that removed the pixel, or a UTM template typo.

Cross-link: Tracking Health explains each state; Sources & Attribution documents the attribution logic that consumes the captured click IDs.

Frequently asked questions

What is a click ID and why does it matter for ad attribution?
A click ID is a unique identifier that an ad network attaches to a landing page URL when a user clicks an ad. gclid identifies a Google Ads click; fbclid identifies a Meta (Facebook/Instagram) Ads click; ttclid identifies a TikTok Ads click. The ad network uses the click ID to match a downstream conversion (purchase, signup) back to the specific click that drove it. Without it, the conversion is harder to credit to the ad, campaigns get under-credited and bidding misallocates spend.
Why do click IDs disappear if I just store them in the browser?
Three reasons. (1) Safari ITP caps storage written by scripts, cookies and localStorage alike, at 7 days. (2) iOS 17 Link Tracking Protection can strip the click ID from the URL before the page loads, so no script ever sees it. (3) Cross-device journeys: a click on mobile and a purchase on desktop do not share browser storage. Admaxxer's pixel keeps click IDs in first-party localStorage for 90 days, with an in-memory fallback, so it is still subject to the Safari limit; a server-set cookie is not available yet. Admaxxer joins an order back to the earlier visit by hashed email, which helps with cross-device journeys when the same email is used.
Which click ID formats does Admaxxer capture?
Thirteen by default: gclid, gbraid and wbraid (Google Ads), fbclid (Meta), ttclid (TikTok), msclkid (Microsoft Ads), scid (Snapchat), rdt_cid (Reddit), epik (Pinterest), li_fat_id (LinkedIn), twclid (X), _kx (Klaviyo email links) and ko_click_id. All are kept for attribution in Admaxxer. Server-side forwarding is narrower: fbclid builds the fbc field for Meta CAPI and ttclid goes to the TikTok Events API, for the ad accounts you connect and turn server-side sending on for. Forwarding gclid to Google Ads is not available yet.
How does Admaxxer forward click IDs to Meta CAPI and TikTok?
From the server, when an order lands and sending is turned on for that ad account. For Meta, Admaxxer sends the fbc and fbp values captured for the visitor (Meta's own cookies when present, otherwise an fbc built from the fbclid) with hashed email and phone, IP and user agent, as a Purchase event whose event_id is the order or payment ID. For TikTok, it sends a CompletePayment event with hashed customer data and the captured ttclid when there is one. Forwarding to Google Ads is not available yet; if you use Google Enhanced Conversions, set it up in Google Ads itself. Your browser-side tags must use the same order ID so each order counts once.
Is storing click IDs in first-party storage compliant with GDPR/CCPA?
That depends on your consent setup and legal advice. Admaxxer's pixel has a consent mode: add data-require-consent="true" to the script tag and it sends nothing until your banner calls admaxxer.optIn(); admaxxer.optOut() stops tracking and remembers the choice. Not available yet: Meta's Limited Data Use flag, Google's restricted data processing setting, and gating server-side sends on a per-order consent signal. Server-side sending is off until you turn it on; if your legal advice requires those controls, keep it off for the affected regions.

Run this playbook in your own dashboard

Admaxxer ships the pixel + server-side purchases to Meta, TikTok and Klaviyo + Maxxer AI agent + cohort analytics out of the box. The playbook above becomes a live surface in your account after a 5-minute setup.

Start a 7-day trial See pricing