Documentation

Everything you need to know for quick Consentio implementation

TikTok Pixel

TikTok Pixel integration with Consentio

What is TikTok Pixel

A measurement tool for tracking conversions and optimising campaigns on TikTok. TikTok Pixel allows you to measure ad effectiveness, create custom audiences and optimise ad delivery.

Cookie category

TikTok Pixel belongs to the marketing category.

Consentio category GCM signal
marketing ad_storage, ad_user_data, ad_personalization

Installation with Consentio

Add the TikTok Pixel code with type="text/plain" and data-category="marketing" attributes. The Consentio script will activate the pixel only after marketing cookie consent is granted.

HTML
<!-- TikTok Pixel -->
<script type="text/plain" data-category="marketing">
  !function (w, d, t) {
    w.TiktokAnalyticsObject=t;var ttq=w[t]=w[t]||[];ttq.methods=["page","track","identify","instances","debug","on","off","once","ready","alias","group","enableCookie","disableCookie","holdConsent","revokeConsent","grantConsent"],ttq.setAndDefer=function(t,e){t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}};for(var i=0;i<ttq.methods.length;i++)ttq.setAndDefer(ttq,ttq.methods[i]);ttq.instance=function(t){for(var e=ttq._i[t]||[],n=0;n<ttq.methods.length;n++)ttq.setAndDefer(e,ttq.methods[n]);return e};ttq.load=function(e,n){var r="https://analytics.tiktok.com/i18n/pixel/events.js",o=n&&n.partner;ttq._i=ttq._i||{},ttq._i[e]=[],ttq._i[e]._u=r,ttq._t=ttq._t||{},ttq._t[e]=+new Date,ttq._o=ttq._o||{},ttq._o[e]=n||{};var i=d.createElement("script");i.type="text/javascript",i.async=!0,i.src=r+"?sdkid="+e+"&lib="+t;var a=d.getElementsByTagName("script")[0];a.parentNode.insertBefore(i,a)};
    ttq.load('YOUR_PIXEL_ID');
    ttq.page();
  }(window, document, 'ttq');
</script>
Note: Replace YOUR_PIXEL_ID with the actual ID from TikTok Ads Manager → Assets → Events.

JavaScript API alternative

Dynamically load TikTok Pixel after consent is granted:

JavaScript
Consentio.onConsentChange((consent) => {
  if (consent.marketing) {
    !function (w, d, t) {
      w.TiktokAnalyticsObject=t;var ttq=w[t]=w[t]||[];
      ttq.methods=["page","track","identify","instances","debug",
      "on","off","once","ready","alias","group","enableCookie",
      "disableCookie","holdConsent","revokeConsent","grantConsent"];
      ttq.setAndDefer=function(t,e){t[e]=function(){
        t.push([e].concat(Array.prototype.slice.call(arguments,0)))}};
      for(var i=0;i<ttq.methods.length;i++)ttq.setAndDefer(ttq,ttq.methods[i]);
      ttq.instance=function(t){for(var e=ttq._i[t]||[],n=0;
        n<ttq.methods.length;n++)ttq.setAndDefer(e,ttq.methods[n]);return e};
      ttq.load=function(e,n){var r="https://analytics.tiktok.com/i18n/pixel/events.js";
        ttq._i=ttq._i||{},ttq._i[e]=[],ttq._i[e]._u=r,
        ttq._t=ttq._t||{},ttq._t[e]=+new Date,ttq._o=ttq._o||{},
        ttq._o[e]=n||{};var i=d.createElement("script");
        i.type="text/javascript",i.async=!0,
        i.src=r+"?sdkid="+e+"&lib="+t;
        var a=d.getElementsByTagName("script")[0];
        a.parentNode.insertBefore(i,a)};
      ttq.load('YOUR_PIXEL_ID');
      ttq.page();
    }(window, document, 'ttq');
  }
})

Google Consent Mode v2

TikTok Pixel does not natively support Google Consent Mode v2. Therefore, you must use script blocking via the type="text/plain" attribute with data-category="marketing", as described above.

Consentio ensures that the pixel only loads after marketing consent is granted. Category mapping:

Consentio category GCM signal Description
marketing ad_storage Ad storage
marketing ad_user_data Sharing user data with advertising platforms
marketing ad_personalization Ad personalisation

Verification

  1. Install the TikTok Pixel Helper extension in Chrome
  2. Before granting consent: the pixel should not send any events
  3. After granting marketing consent: the pixel should send a PageView event
  4. Verify in TikTok Ads Manager → Assets → Events that events are being recorded correctly
Facebook PixelMicrosoft Ads