Back to Blog
Technical

TikTok Pixel GDPR Consent: Complete Guide

GetCookies teamDecember 25, 20248 min read
TikTokAdvertisingGDPRConsent

TLDR: TikTok Pixel requires consent in the EU. GetCookies automatically calls ttq.enableCookie()/disableCookie() based on user choice. One script tag, compliant TikTok ads.

Read full summary

TikTok advertising is growing fast. But like all tracking pixels, TikTok Pixel requires proper consent handling. This guide covers TikTok's consent API and how GetCookies automates it.

Summary by Claude AI

TikTok Ads Are Growing. Is Your Pixel Compliant?

TikTok advertising spend grew 350% in the past two years. Brands are pouring budget into the platform.

But here's what most marketers miss: TikTok Pixel has the same GDPR requirements as Meta Pixel. Fire it without consent in the EU, and you're breaking the law.

The good news? TikTok provides a consent API. The better news? GetCookies calls it automatically.

TikTok's Consent API

TikTok provides cookie consent methods:

// Disable cookies (before consent)
ttq.disableCookie();

// Enable cookies (after consent)
ttq.enableCookie();

When cookies are disabled:

  • Limited data collection
  • No persistent identifiers
  • Reduced attribution accuracy

When cookies are enabled:

  • Full pixel functionality
  • Cross-session tracking
  • Complete conversion attribution

The Standard Implementation (Manual)

Without a CMP, you need:

<script>
!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"];
  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 i="https://analytics.tiktok.com/i18n/pixel/events.js";
  ttq._i=ttq._i||{};ttq._i[e]=[];ttq._i[e]._u=i;ttq._t=ttq._t||{};ttq._t[e]=+new Date;ttq._o=ttq._o||{};ttq._o[e]=n||{};
  var o=document.createElement("script");o.type="text/javascript";o.async=!0;o.src=i+"?sdkid="+e+"&lib="+t;
  var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(o,a)};

  // CRITICAL: Disable cookies by default
  ttq.disableCookie();

  ttq.load('YOUR_PIXEL_ID');
  ttq.page();
}(window, document, 'ttq');
</script>

Then you need to build consent UI, handle consent changes, manage state...

The GetCookies Way

<head>
  <!-- GetCookies -->
  <script src="https://getcookies.co/api/v1/widget/loader.js"
          data-domain-id="YOUR_DOMAIN_ID"
          async></script>

  <!-- TikTok Pixel -->
  <script>
    !function (w, d, t) {...}
    ttq.load('YOUR_PIXEL_ID');
    ttq.page();
  </script>
</head>

GetCookies automatically:

  1. Calls ttq.disableCookie() before user makes a choice
  2. Calls ttq.enableCookie() when marketing consent is given
  3. Handles consent changes in real-time
  4. Persists consent across sessions

Add both scripts. Done.

Implementation Patterns

Pattern 1: Standard (Recommended)

Add both scripts, GetCookies handles the rest:

<script src="https://getcookies.co/api/v1/widget/loader.js"
        data-domain-id="YOUR_DOMAIN_ID"
        async></script>

<script>
  !function (w, d, t) {
    // Standard TikTok pixel code
  }(window, document, 'ttq');

  ttq.load('YOUR_PIXEL_ID');
  ttq.page();
</script>

Pattern 2: Block Until Consent

Only load pixel after consent:

<script type="text/plain" data-cookieconsent="marketing">
  !function (w, d, t) {...}(window, document, 'ttq');
  ttq.load('YOUR_PIXEL_ID');
  ttq.page();
</script>

Pattern 3: JavaScript API

Dynamic loading based on consent:

window.addEventListener('getcookies:consent', (e) => {
  if (e.detail.marketing && !window.ttqLoaded) {
    loadTikTokPixel();
    window.ttqLoaded = true;
  }
});

function loadTikTokPixel() {
  !function (w, d, t) {...}(window, document, 'ttq');
  ttq.load('YOUR_PIXEL_ID');
  ttq.page();
}

Event Tracking

After consent, track events normally:

// Page view (usually automatic)
ttq.page();

// Complete Payment
ttq.track('CompletePayment', {
  content_id: 'product_123',
  content_type: 'product',
  content_name: 'Awesome Product',
  quantity: 1,
  value: 29.99,
  currency: 'USD'
});

// Add to Cart
ttq.track('AddToCart', {
  content_id: 'product_123',
  content_type: 'product',
  value: 29.99,
  currency: 'USD'
});

// View Content
ttq.track('ViewContent', {
  content_id: 'product_123',
  content_type: 'product'
});

TikTok Events API (Server-Side)

For better attribution, combine with server-side tracking:

import requests

url = "https://business-api.tiktok.com/open_api/v1.3/pixel/track/"

headers = {
    "Access-Token": "YOUR_ACCESS_TOKEN",
    "Content-Type": "application/json"
}

payload = {
    "pixel_code": "YOUR_PIXEL_ID",
    "event": "CompletePayment",
    "event_id": "unique_event_id",  # For deduplication
    "timestamp": "2024-01-15T10:30:00Z",
    "properties": {
        "content_id": "product_123",
        "value": 29.99,
        "currency": "USD"
    }
}

response = requests.post(url, headers=headers, json=payload)

Testing

TikTok Pixel Helper

  1. Install the TikTok Pixel Helper browser extension
  2. Load your site in incognito
  3. Before consent: Pixel should show limited mode
  4. After marketing consent: Full functionality

TikTok Events Manager

  1. Go to TikTok Ads Manager → Events
  2. Use Test Events feature
  3. Verify events fire correctly after consent

Common Issues

Pixel not detected Check browser console for errors. Verify script order.

Events not tracking Verify ttq.enableCookie() is called after consent:

console.log('TikTok Pixel loaded:', !!window.ttq);

Attribution issues Use Events API for server-side tracking to improve accuracy.

Best Practices

  1. Use both browser and server-side tracking - Better attribution
  2. Include event IDs - For deduplication when using both methods
  3. Test in TikTok Ads Manager - Before running campaigns

The Bottom Line

TikTok Pixel needs consent management. GetCookies:

  1. Detects TikTok Pixel automatically
  2. Calls consent APIs at the right time
  3. Handles all edge cases

One script tag. Full compliance.


Ready to make your TikTok Pixel compliant?

Set up GetCookies in 5 minutes

G

GetCookies team

Written and maintained by the GetCookies team at Getia AS in Oslo, Norway. This article is general information about cookie consent, not legal advice.

Scan Your Own Site for Free

The free plan runs the banner on one site with three cookie scans a month. No card, no sales call.