# 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.

Source: https://cookiequiet.com/platforms/tiktok-pixel
Published: 2026-10-21
Publisher: Cookiequiet

## Steps

1. **Get the base code** In TikTok Events Manager, open your pixel and copy the base code for manual installation. It loads events.js from analytics.tiktok.com and calls ttq.load with your pixel ID and ttq.page().
2. **Paste it after the Cookiequiet snippet** Put the base code in the head of every page, right after the Cookiequiet snippet.
3. **Mark it** Change the opening tag to type="text/plain" with data-cq-category="marketing" and leave the code inside unchanged.
4. **Or use TikTok's consent mode** Add holdConsent, revokeConsent and grantConsent to the ttq.methods array, call ttq.holdConsent() before ttq.load(), and grant or revoke from a cq:consent listener.
5. **Gate event calls** Calls such as ttq.track('CompletePayment') in page code must sit in marked scripts or run after the pixel, so they follow the same choice.
6. **Test with Reject all** In a private window, click Reject all and check that no _ttp cookie is set and no event reaches TikTok. Accept all, reload, and check the events in TikTok Pixel Helper or Events Manager.

## 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](/guides/switch-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](/platforms/google-tag-manager) 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](/platforms/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?

1. Open the site in a private window and click **Reject all**. No `_ttp` cookie, and with option 1 no request to `analytics.tiktok.com`.
2. Clear the cookies, click **Accept all**, reload: the pixel loads, `_ttp` appears, and TikTok Pixel Helper shows the page event.
3. In Events Manager, test events show the visit.
4. 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.

## Questions

### Which consent category does the TikTok Pixel belong to?

Marketing. TikTok classes all of the pixel's cookies as advertising cookies, used to measure campaigns and personalise ads on TikTok.

### What do ttq.holdConsent, ttq.grantConsent and ttq.revokeConsent do?

holdConsent, called before ttq.load, queues events without sharing them. grantConsent shares them, including those queued in the session, and revokeConsent stops sharing and drops the queue. They must be added to the ttq.methods array of the base code.

### Does the TikTok Pixel support Google Consent Mode?

Consent Mode governs Google tags. TikTok mentions it only for configuring Google tags in Tag Manager. Gate the pixel with a cq_consent trigger, a marked base code or TikTok's own consent calls.

### How long do TikTok's cookies last?

TikTok lists 13 months from the last date they were used for _ttp, ttcsid, ttclid and the Pangle cookie.

## Sources

- [TikTok for Business: About using cookies with TikTok Pixel](https://ads.tiktok.com/help/article/using-cookies-with-tiktok-pixel?lang=en)
- [TikTok for Business: How to use cookies with TikTok Pixel](https://ads.tiktok.com/help/article/how-to-use-cookies-with-tiktok-pixel?lang=en)
- [TikTok API for Business: Pixel cookie consent mode](https://business-api.tiktok.com/portal/docs/pixel-cookie-consent-mode/v1.3)
- [Google Tag Manager Help: Custom event trigger](https://support.google.com/tagmanager/answer/7679219)
