Fix guide · Shopify · medium · about 30 min

TikTok click ID (ttclid) lost on Shopify

For the finding “Click ID from TikTok ads is not stored”. Also for: Any website, 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 store should read it, store it in a first-party cookie that is also named ttclid, and send it with its events, so that an add to cart or a purchase later in the visit can be tied back to the ad click. On your store, 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.
  • Server events sent through the TikTok Events API usually rely on the same click ID, so they lose it too.

How to confirm it yourself

Our check opens your page in a browser in the EU as if the visitor arrived from a TikTok ad, accepts the cookie banner and looks for the click ID. If our report shows a redirect chain, start there: it often shows where the click ID was dropped.

  1. Open a private (incognito) window, open developer tools (F12) on Network, and tick Preserve log so redirects stay visible.
  2. Open the exact URL your ads use, with a made-up click ID added: https://yourstore.com/products/example?ttclid=test123. (This sends a normal page view to your own pixel. It does not create an ad click.)
  3. If one of the first requests is a redirect (301, 302, 307, 308), click it and check its Location header. Does the new address still contain ttclid=test123?
  4. Accept the cookie banner and wait a few seconds. Where consent is required, a pixel that follows Shopify’s customer privacy settings waits for it, so the cookie may appear only after you accept.
  5. Go to Application > Cookies (Chrome) or Storage > Cookies (Firefox), select your store’s domain and look for 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, open an event request and look for your test value in the payload.

If the ttclid cookie is missing on your store’s domain, 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 after consent, and it must be able to see the address and write cookies on your domain.

  1. Point your ads at the final address. Your primary domain is set under Settings > Domains; your other domains, including the .myshopify.com address, redirect to it. Use the exact final address in every ad (primary domain, https, and the market folder such as /en-de if you use one), so visitors land without a redirect. TikTok notes the click ID can be up to 1,000 characters long; do not truncate it.
  2. Test automatic redirection for your markets. If automatic redirection is on (Online Store > Preferences), visitors may be sent to another domain or folder for their country. Open your ad URL with ?ttclid=test123 through a VPN in each of your main markets and check that the click ID survives.
  3. Check Shopify URL redirects. Redirects under Content > Menus > View URL redirects only work for addresses that no longer exist, and Shopify notes that URLs with query strings might not work as expected. If an ad points to an old address, change the ad to the current page.
  4. Check redirects outside Shopify and in apps: domain forwarding at your registrar, link shorteners, link-in-bio pages, and apps that send visitors to another address (country selectors, A/B tests, age checks). These are common places where the query string is dropped.
  5. 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 never fires after “Accept”, or only on the next page (where the address no longer has ttclid), the cookie is never written. For app pixels under Settings > Customer events, Shopify documents that it starts them after consent and replays the events that already happened on the page. If the pixel does not fire after “Accept” at all, see “TikTok Pixel does not fire after consent”.
  6. Check custom pixels. Shopify documents that custom pixels run in a sandbox frame that cannot access the top frame: there, the page address is the sandbox address, not your store page, and cookies on your store’s domain have to go through Shopify’s browser.cookie API instead of document.cookie. So TikTok’s base code pasted into a custom pixel (directly or through GTM) may not see ttclid in the address, and may not be able to store ttclid and _ttp on your domain. Run the test above and check that both cookies end up on your store’s domain. If they do not:
    • use the TikTok app’s pixel instead (Sales channels > TikTok), remove the custom pixel so events are not sent twice, and repeat the test; or
    • have a developer pass the click ID explicitly: Shopify provides init.context.document.location, a snapshot of the top page’s address, and browser.cookie, which reads and writes cookies on the top frame.
  7. 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; when they are off, no new first-party cookies are set. TikTok’s Pixel Helper reports this as “First-Party Cookies Not Found”.
  8. Check your consent app does not delete the cookie. Some consent tools delete marketing cookies they consider unapproved. After “Accept”, ttclid and _ttp should stay.
  9. If you send Events API events yourself (not through the TikTok app), pass the click ID as user.ttclid and the _ttp value as user.ttp. TikTok also reads a ttclid parameter from page.url if it is there.

Common causes

  • Ads link to an address that goes through a redirect outside Shopify (registrar forwarding, a link shortener, a link-in-bio tool) that drops the query string.
  • An app redirects visitors to another page or country version without keeping the query string.
  • An ad points to an old address that relies on a URL redirect.
  • The pixel never fires after consent on the landing page, so it never reads ttclid.
  • The TikTok Pixel runs in a custom pixel and cannot see the real page address or write cookies on the store’s domain.
  • First-party cookies are switched off in the pixel’s settings.

How to verify the fix

  1. Repeat the test above with the exact ad URL: no redirect drops ?ttclid=test123, and after accepting cookies the ttclid cookie on your store’s domain holds test123.
  2. Open another page of the store: 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