How to set up the TikTok Pixel with Cookiequiet
The TikTok Pixel sets advertising cookies such as _ttp and ttclid on your domain for 13 months, so it belongs in the marketing category and needs consent first in the EEA and the UK. Mark the base code with type="text/plain" and data-cq-category="marketing" so it runs only after consent, or use TikTok's own consent mode: ttq.holdConsent() before ttq.load(), then ttq.grantConsent() or ttq.revokeConsent() from Cookiequiet's cq:consent event.Steps
What does the TikTok Pixel set?
TikTok's help centre lists the cookies the pixel uses, all classed by TikTok as advertising cookies that last 13 months from the last date they were used:
| Cookie | Domain | Type |
|---|---|---|
_ttp | your website domain | first-party |
_ttp | .tiktok.com | third-party |
ttcsid, ttcsid_<pixel code> | your website domain | first-party |
ttclid | your website domain | first-party |
_pangle | analytics.pangle-ads.com | third-party |
TikTok describes their purpose as measuring and improving ad campaigns and personalising the experience, including ads, on TikTok. First-party cookies are on by default and can be switched off in the pixel settings; third-party cookies are on by default. Because the pixel links visits to people on TikTok for ads and audiences, it belongs in the marketing category in Cookiequiet. TikTok's own guidance says that if you must obtain consent, your site has to stop setting and using cookies when a visitor declines, with a tag manager, a consent management platform or TikTok's pixel consent mode.
Option 1: mark the base code
Put the base code right after the Cookiequiet snippet and change only the opening tag:
html<script type="text/plain" data-cq-category="marketing">/* TikTok Pixel base code from Events Manager, unchanged:it defines ttq, then calls ttq.load('YOUR_PIXEL_ID') and ttq.page() */</script>
Cookiequiet runs it when marketing is granted: at once on later visits where the stored choice includes it, and at the moment of the click when the visitor accepts during the visit. Until then nothing loads from analytics.tiktok.com and no _ttp cookie is set. Event calls in your page code, such as ttq.track('CompletePayment'), go in scripts marked the same way. Tags already marked for CookieYes or Cookiebot keep working; see switching from CookieYes.
Option 2: TikTok's pixel consent mode
TikTok's developer documentation describes a "default opt-out" mode for sites that must ask first. Add "holdConsent", "revokeConsent" and "grantConsent" to the ttq.methods array of the base code, and call ttq.holdConsent() before ttq.load(). The pixel then queues events without sharing them. ttq.grantConsent() sends them, including those queued in the session; ttq.revokeConsent() drops them and stops sharing. TikTok notes that revoking does not affect data already shared. Connect it to Cookiequiet with the cq:consent event, which carries the granted categories in detail.categories and the stored choice, if any, in detail.state:
html<script>window.addEventListener('cq:consent', function (e) {if (!window.ttq) return;if (e.detail.categories.indexOf('marketing') >= 0) ttq.grantConsent();else if (e.detail.state) ttq.revokeConsent();});</script>
The listener only revokes once the visitor has made a choice, so events stay queued while the banner is open. Place it before the base code. Note the difference with option 1: here the TikTok script loads on every page, and only the sharing waits for consent. If the auto-blocker is on and the base code runs after Cookiequiet (from Tag Manager, for example), Cookiequiet holds analytics.tiktok.com under marketing until consent anyway, so option 1 is the simpler choice where you can edit the code.
What about Google Tag Manager?
TikTok documents a Tag Manager setup through Events Manager. To put it behind consent, give the pixel tag a Custom Event trigger on cq_consent, Some Custom Events, condition cq_marketing equals true, with Tag firing options set to Once per page, and add ad_storage under Require additional consent for tag to fire. Cookiequiet pushes cq_consent on each page load where a choice is stored and after every choice, and grants ad_storage with marketing. The Google Tag Manager guide explains the variables.
EU-specific points
- The Events API sends the same conversions from your server. It describes the same visitor, so send those events only for visitors whose consent log entry includes marketing, as with the Meta Pixel and its Conversions API.
- Advanced Matching sends hashed email addresses or phone numbers with events; it is part of the same marketing purpose.
- List the pixel's cookies with their 13-month lifetime in your cookie policy; the scanner names the TikTok Pixel when it finds it.
How do I test it?
- Open the site in a private window and click Reject all. No
_ttpcookie, and with option 1 no request toanalytics.tiktok.com. - Clear the cookies, click Accept all, reload: the pixel loads,
_ttpappears, and TikTok Pixel Helper shows the page event. - In Events Manager, test events show the visit.
- Check the consent log in the Cookiequiet dashboard.
Cookiequiet is free for one website with geo-targeting; Starter is €3 per website per month with unlimited pageviews.