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.
- Open a private (incognito) window, open developer tools (F12) on Network, and tick Preserve log so redirects stay visible.
- 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.) - 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 containttclid=test123? - 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.
- Go to Application > Cookies (Chrome) or Storage > Cookies (Firefox), select your store’s domain and look for
ttclid. It should holdtest123. You should also see_ttp, the pixel’s browser ID. - 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.
- Point your ads at the final address. Your primary domain is set under Settings > Domains; your other domains, including the
.myshopify.comaddress, redirect to it. Use the exact final address in every ad (primary domain,https, and the market folder such as/en-deif 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. - 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=test123through a VPN in each of your main markets and check that the click ID survives. - 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.
- 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.
- Make sure the pixel runs on the landing page after consent. The pixel reads
ttclidfrom 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 hasttclid), 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”. - 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.cookieAPI instead ofdocument.cookie. So TikTok’s base code pasted into a custom pixel (directly or through GTM) may not seettclidin the address, and may not be able to storettclidand_ttpon 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, andbrowser.cookie, which reads and writes cookies on the top frame.
- 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”.
- Check your consent app does not delete the cookie. Some consent tools delete marketing cookies they consider unapproved. After “Accept”,
ttclidand_ttpshould stay. - If you send Events API events yourself (not through the TikTok app), pass the click ID as
user.ttclidand the_ttpvalue asuser.ttp. TikTok also reads attclidparameter frompage.urlif 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
- Repeat the test above with the exact ad URL: no redirect drops
?ttclid=test123, and after accepting cookies thettclidcookie on your store’s domain holdstest123. - Open another page of the store:
ttclidis still there. - 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
- TikTok Business Help Center, TikTok Click ID (
ttclidappended to landing page URLs): https://ads.tiktok.com/resources/help/article/tiktok-click-id?lang=en - TikTok API for Business, Send TikTok Click ID (ttclid) (pixel stores it in a first-party cookie named
ttclid, up to 1,000 characters,user.ttclid, parsed frompage.url): https://business-api.tiktok.com/portal/docs?id=1771100879787009 - TikTok Business Help Center, Using cookies with TikTok Pixel (
ttclidand_ttpfirst-party cookies, on by default, no new cookies when off): https://ads.tiktok.com/resources/help/article/using-cookies-with-tiktok-pixel?lang=en - TikTok API for Business, Events API 2.0 setup guide for Web (first-party cookies in pixel Settings): https://business-api.tiktok.com/portal/docs?id=1771100865818625
- TikTok API for Business, Send TikTok Cookie (_ttp) (
user.ttp): https://business-api.tiktok.com/portal/docs?id=1771100936446977 - TikTok Business Help Center, TikTok Pixel Helper (“First-Party Cookies Not Found”): https://ads.tiktok.com/resources/help/article/tiktok-pixel-helper-2.0?lang=en
- Shopify Help Center, Change your primary domain (other domains redirect to the primary domain): https://help.shopify.com/en/manual/domains/domain-type/change-primary-domain
- Shopify Help Center, Set up automatic storefront redirection for your customers: https://help.shopify.com/en/manual/international/automatic-redirection
- Shopify Help Center, Creating and managing URL redirects (broken URLs only; query strings): https://help.shopify.com/en/manual/online-store/menus-and-links/url-redirect
- Shopify.dev, About web pixels (app pixels start after consent and replay earlier events; custom pixels run in a lax sandbox iframe that cannot access the top frame): https://shopify.dev/docs/apps/build/marketing/pixels
- Shopify.dev, Web Pixels API
browser(browser.cookiereplacesdocument.cookieand sets cookies on the top frame): https://shopify.dev/docs/api/web-pixels-api/standard-api/browser - Shopify.dev, Web Pixels API
init(init.context.document.location, a snapshot of the top frame’s location): https://shopify.dev/docs/api/web-pixels-api/standard-api/init - Shopify Help Center, Pixels overview: https://help.shopify.com/en/manual/promoting-marketing/pixels/overview
More TikTok guides
- TikTok Pixel fires before cookie consent on Shopify
- TikTok Pixel not firing after cookie consent on Shopify
- Repeated TikTok event IDs drop real conversions: how to fix
- Duplicate TikTok Pixel events on Shopify
- TikTok Pixel events have no event ID on Shopify
- TikTok Pixel tracks a button on desktop but not on mobile
- Two TikTok Pixels on one site: when it's fine, how to fix
- TikTok Events API deduplication: match the pixel's event_id
- How to set up the TikTok Events API (with deduplication)