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:
```javascript
// 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:
```html
```
Then you need to build consent UI, handle consent changes, manage state...
## The GetCookies Way
```html
```
**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:
```html
```
### Pattern 2: Block Until Consent
Only load pixel after consent:
```html
```
### Pattern 3: JavaScript API
Dynamic loading based on consent:
```javascript
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:
```javascript
// 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:
```python
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:
```javascript
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](https://getcookies.co)