Fix guide · Any website · medium · about 30 min

TikTok click ID (ttclid) lost after an ad click: how to fix it

For the finding “Click ID from TikTok ads is not stored”. Also for: Shopify, WordPress, Webflow, Framer.

What this means

When someone clicks a TikTok ad, TikTok adds a click ID to the landing page address: ?ttclid=.... The TikTok Pixel on your site reads it, stores it in a first-party cookie that is also named ttclid, and sends it with its events, so that a lead or purchase later in the visit (or on a later visit) can be tied back to the ad click.

On your site, the click ID did not make it: it was not stored, or not sent with the pixel’s events.

Why it costs you money:

  • TikTok has a weaker link between ad clicks and conversions, which lowers attribution and reported results.
  • Campaigns optimize on less complete data, so you may pay more per result.
  • If you send server events through the TikTok Events API, they usually take the click ID from the same cookie. If it is missing in the browser, it is missing on the server too.

How to confirm it yourself

Our check opens your page in a browser in the EU as if arriving from a TikTok ad, with a test click ID in the URL, accepts the cookie banner, and then looks for the click ID. If our report shows a redirect chain, look at it first: it often shows exactly where the parameter was dropped.

To repeat this yourself:

  1. Open a private (incognito) window and open developer tools (F12) on the Network tab. Tick Preserve log so redirects stay visible.
  2. Open your page with a made-up click ID added, for example https://example.com/?ttclid=test123. (This sends a normal page view to your own pixel. It does not create an ad click.)
  3. Look at the first requests in the Network list. If you see a 301, 302, 307 or 308 redirect, click it and check the Location header: does the new address still contain ttclid=test123? If not, the redirect drops the click ID before any script on your site runs.
  4. Accept the cookie banner and wait a few seconds.
  5. Open the Application tab (Chrome) or Storage tab (Firefox), then Cookies for your domain, and find ttclid. It should hold test123. You should also see _ttp, the pixel’s browser ID.
  6. Filter the Network tab by analytics.tiktok.com/api/v2/pixel and open an event request: the click ID is passed in the event’s context (look for your test value in the payload).

If the ttclid cookie is missing, or holds something else, the click ID is being lost.

How to fix

Work through the chain: the link must arrive with ttclid, the pixel must run on that page, and it must be allowed to write first-party cookies.

  1. Fix redirects that drop the query string. This is the most common cause, and it happens before any tracking code can run.
    • Make your ads link straight to the final address: the exact protocol (https), host (with or without www) and path (with or without the trailing slash) your site ends up on.
    • Check redirect rules at your host, CDN or server (http to https, non-www to www or back, old paths to new ones, language or country redirects). Each rule should keep the query string; many tools call this “preserve query string” or “forward parameters”.
    • Avoid link shorteners and tracking redirectors in ad URLs unless you have tested that they pass ttclid through. TikTok notes the click ID can be up to 1,000 characters long; do not truncate it.
  2. Make sure the pixel runs on the landing page after consent. The pixel reads ttclid from the address of the page it runs on. If it waits for consent and does not start after the visitor accepts, or only starts on the next page (where the URL no longer has ttclid), the cookie is never written. See “TikTok Pixel does not fire after consent”.
  3. Check that first-party cookies are on. In TikTok Events Manager, open Tools > Events > Data sources, select your pixel and open the Settings tab. First-party cookies are on by default, but they can be switched off there; TikTok says that when they are off, no new first-party cookies are set. TikTok’s Pixel Helper reports this as “First-Party Cookies Not Found”.
  4. Check that nothing rewrites the URL first. Some sites, single-page apps and “clean URL” scripts strip unknown parameters from the address bar on load. If the pixel loads after that, it never sees ttclid. TikTok recommends placing the base code as early as possible in the <head>.
  5. Check that your consent tool is not deleting the cookie. Some consent tools delete marketing cookies they consider unapproved. After Accept, ttclid and _ttp should stay.
  6. Pass the click ID to your server events. For the Events API, send it as user.ttclid and the _ttp value as user.ttp. TikTok also reads a ttclid parameter from page.url if it is there. If you store the click ID yourself, TikTok recommends keeping it for 28 days or more and refreshing it when a new ttclid arrives.

Common causes

  • A redirect without the query string: http to https, adding www, adding a trailing slash, or a language redirect.
  • A link shortener or tracking redirect in the ad URL.
  • The pixel waits for consent and does not fire after Accept, or only fires on the next page.
  • First-party cookies are switched off in the pixel’s settings.
  • A script strips query parameters before the pixel reads them.
  • Server events are sent without ttclid and ttp.

How to verify the fix

  1. Repeat the test above: no redirect drops ?ttclid=test123, and after accepting cookies the ttclid cookie holds test123.
  2. Open another page on your site: ttclid is still there.
  3. Re-run the check on IsPixelWorking. The issue should be gone, and the redirect chain in the report (if any) should keep the click ID.

Sources

More TikTok guides