TikTok Ads Event Tracking
Overview
TikTok Ads uses the TikTok Pixel for browser-based conversion tracking and the TikTok Events API for server-side measurement. With a predominantly Gen Z audience and short-form video content, TikTok's tracking capabilities enable advertisers to measure web conversions, app installs, and in-app events across the platform's For You feed and branded content.
Standard Events
TikTok provides predefined events optimized for various business objectives:
Ecommerce Events
- CompletePayment - Purchase completed
- AddToCart - Product added to cart
- InitiateCheckout - Checkout process started
- PlaceAnOrder - Order placed (pre-payment)
- AddPaymentInfo - Payment information added
- ViewContent - Product or content page viewed
Lead Generation Events
- SubmitForm - Form submission
- Contact - Contact initiated (phone, chat, email)
- CompleteRegistration - Account registration completed
- Subscribe - Newsletter or service subscription
Engagement Events
- ClickButton - Button or CTA clicked
- Search - Site search performed
- Download - File or app download
- AddToWishlist - Product saved to wishlist
App Events
- OnlineConsult - Online consultation initiated
- OnAppOrderOnWeb - Order placed for app on website
Automatically Tracked
- PageView - Page visit (auto-tracked when pixel loads)
Custom Events
Creating Custom Events
TikTok supports custom events beyond standard events:
// Custom event
ttq.track('CustomEvent', {
content_type: 'product_comparison',
content_id: '12345',
content_name: 'Product Comparison Tool',
value: 0,
currency: 'USD'
});
Note: Custom events can be used for optimization but standard events are recommended for best campaign delivery.
Event Parameters
Enhance events with additional parameters:
ttq.track('CompletePayment', {
content_type: 'product',
content_id: 'SKU_123',
content_name: 'Blue Widget',
quantity: 2,
price: 99.99,
value: 199.98,
currency: 'USD',
content_category: 'Widgets',
order_id: 'ORDER_12345'
});
Advanced Parameters
Additional parameters for enhanced tracking:
ttq.track('CompletePayment', {
// Required ecommerce params
value: 199.98,
currency: 'USD',
// Product details
contents: [
{
content_id: 'SKU_123',
content_name: 'Blue Widget',
content_category: 'Widgets',
quantity: 2,
price: 99.99
}
],
// Additional parameters
order_id: 'ORDER_12345',
shop_id: 'SHOP_001',
description: 'Premium blue widget 2-pack'
});
Ecommerce Events
Purchase Tracking
Complete purchase implementation:
<!-- TikTok Pixel Base Code (on all pages) -->
<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)};
ttq.load('YOUR_PIXEL_ID');
ttq.page();
}(window, document, 'ttq');
</script>
<!-- Purchase Event (on confirmation page) -->
<script>
ttq.track('CompletePayment', {
content_type: 'product',
value: 199.98,
currency: 'USD',
contents: [
{
content_id: 'SKU_123',
content_name: 'Blue Widget',
quantity: 2,
price: 99.99
}
],
order_id: 'ORDER_12345'
});
</script>
Shopping Funnel Tracking
Track complete customer journey:
// View Content (Product Page)
ttq.track('ViewContent', {
content_type: 'product',
content_id: 'SKU_123',
content_name: 'Blue Widget',
content_category: 'Widgets',
price: 99.99,
currency: 'USD'
});
// Add to Cart
ttq.track('AddToCart', {
content_type: 'product',
content_id: 'SKU_123',
content_name: 'Blue Widget',
quantity: 2,
price: 99.99,
value: 199.98,
currency: 'USD'
});
// Initiate Checkout
ttq.track('InitiateCheckout', {
content_type: 'product',
value: 199.98,
currency: 'USD',
contents: [
{
content_id: 'SKU_123',
quantity: 2,
price: 99.99
}
]
});
// Add Payment Info
ttq.track('AddPaymentInfo', {
value: 199.98,
currency: 'USD'
});
// Complete Payment
ttq.track('CompletePayment', {
content_type: 'product',
value: 199.98,
currency: 'USD',
order_id: 'ORDER_12345',
contents: [
{
content_id: 'SKU_123',
quantity: 2,
price: 99.99
}
]
});
Catalog Commerce
For TikTok Shopping and catalog campaigns:
ttq.track('CompletePayment', {
content_type: 'product',
content_id: 'SKU_123', // Must match catalog product ID
value: 99.99,
currency: 'USD',
contents: [
{
content_id: 'SKU_123',
content_name: 'Blue Widget',
quantity: 1,
price: 99.99
}
]
});
Conversion Tracking
Implementation Methods
1. TikTok Pixel (Browser-Side)
Standard JavaScript implementation:
<!-- Standard Pixel Code -->
<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)};
ttq.load('YOUR_PIXEL_ID');
ttq.page();
}(window, document, 'ttq');
</script>
<!-- Event Tracking -->
<script>
ttq.track('CompletePayment', {
value: 99.99,
currency: 'USD'
});
</script>
2. Google Tag Manager
Deploy TikTok Pixel via GTM:
Base Tag:
// GTM Custom HTML Tag - All Pages
<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)};
ttq.load('{{TikTok Pixel ID}}');
ttq.page();
}(window, document, 'ttq');
</script>
Event Tags:
// Purchase Event via GTM
<script>
ttq.track('CompletePayment', {
value: {{Transaction Value}},
currency: 'USD',
order_id: {{Transaction ID}}
});
</script>
3. TikTok Events API
Server-side tracking for enhanced measurement:
// Node.js example
const axios = require('axios');
const crypto = require('crypto');
function hashData(data) {
return crypto.createHash('sha256').update(data.toLowerCase().trim()).digest('hex');
}
const eventData = {
pixel_code: 'YOUR_PIXEL_ID',
event: 'CompletePayment',
event_id: 'ORDER_12345_' + Date.now(), // Deduplication ID
timestamp: new Date().toISOString(),
context: {
user_agent: 'Mozilla/5.0...',
ip: '192.168.1.1',
page: {
url: 'https://example.com/checkout/success',
referrer: 'https://example.com/checkout'
},
user: {
external_id: hashData('USER_12345'),
email: hashData('user@example.com'),
phone_number: hashData('+15551234567'),
ttp: 'ttp_cookie_value' // _ttp cookie from browser
}
},
properties: {
value: 199.98,
currency: 'USD',
content_type: 'product',
contents: [
{
content_id: 'SKU_123',
quantity: 2,
price: 99.99
}
]
}
};
const response = await axios.post(
'https://business-api.tiktok.com/open_api/v1.3/event/track/',
{
event_source: 'web',
event_source_id: 'YOUR_PIXEL_ID',
data: [eventData]
},
{
headers: {
'Access-Token': 'YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
}
}
);
4. App Event Tracking
For mobile app conversions via TikTok SDK:
iOS (Swift):
import TikTokBusinessSDK
TikTokBusiness.track(
event: .completePayment,
withProperties: [
"value": 99.99,
"currency": "USD",
"content_id": "SKU_123"
]
)
Android (Kotlin):
import com.tiktok.analytics.TikTokBusinessSDK
TikTokBusinessSDK.getInstance().trackEvent(
"CompletePayment",
mapOf(
"value" to 99.99,
"currency" to "USD",
"content_id" to "SKU_123"
)
)
Advanced Matching
Improve conversion matching with user identifiers:
// Enhanced matching via pixel
ttq.identify({
email: hashEmail('user@example.com'), // SHA256 hash
phone_number: hashPhone('+15551234567'),
external_id: 'USER_12345'
});
ttq.track('CompletePayment', {
value: 99.99,
currency: 'USD'
});
function hashEmail(email) {
return CryptoJS.SHA256(email.toLowerCase().trim()).toString();
}
Event Deduplication
Prevent duplicate events when using Pixel + Events API:
// Browser-side
const eventId = 'ORDER_12345_' + Date.now();
ttq.track('CompletePayment', {
value: 99.99,
currency: 'USD',
event_id: eventId // Deduplication ID
});
// Server-side Events API with matching event_id
Offline Conversions
Events API for Offline Data
Upload offline conversions via Events API:
import requests
import hashlib
import time
def hash_value(value):
return hashlib.sha256(value.lower().strip().encode()).hexdigest()
# Offline conversion
event_data = {
"pixel_code": "YOUR_PIXEL_ID",
"event": "CompletePayment",
"event_id": f"OFFLINE_ORDER_{int(time.time())}",
"timestamp": time.time(),
"context": {
"user": {
"email": hash_value("customer@example.com"),
"phone_number": hash_value("+15551234567"),
"external_id": "CRM_ID_12345"
}
},
"properties": {
"value": 149.99,
"currency": "USD",
"content_type": "product"
}
}
headers = {
"Access-Token": access_token,
"Content-Type": "application/json"
}
response = requests.post(
"https://business-api.tiktok.com/open_api/v1.3/event/track/",
json={
"event_source": "offline",
"event_source_id": "YOUR_PIXEL_ID",
"data": [event_data]
},
headers=headers
)
Mobile Measurement Partners (MMPs)
Integrate with MMPs for app attribution:
Supported MMPs:
- AppsFlyer
- Adjust
- Kochava
- Branch
- Singular
- Tenjin
Benefits:
- Automatic app install tracking
- In-app event attribution
- Deep linking
- Fraud prevention
- SKAdNetwork support for iOS
Attribution
Attribution Windows
Configure attribution settings:
Default Windows:
- Click: 7 days
- View: 1 day
Customizable Options:
- Click: 1, 7, or 28 days
- View: 1 or 7 days
Configure in: TikTok Ads Manager > Assets > Events > Attribution Settings
Attribution Models
TikTok uses last-touch attribution:
- Last clicked ad gets 100% credit
- If no click, last viewed ad gets credit (within view window)
Video View Attribution
Unique to video platforms:
- 2-second view - User watched ad for 2+ seconds
- 6-second view - User watched ad for 6+ seconds
- Views count toward view-through conversions
Cross-Device Attribution
Automatic for logged-in TikTok users:
- Track user across mobile and web
- Unified user identification
- More complete conversion paths
Debugging & Validation
TikTok Pixel Helper
Chrome extension for pixel validation:
- Install TikTok Pixel Helper extension
- Visit page with TikTok Pixel
- Review:
- Pixel ID and status
- Events fired
- Event parameters
- Errors or warnings
Test Events
Test pixel before going live:
- Navigate to Events Manager
- Select your pixel
- Click Test Events
- Use Test Event Code or browser testing
- Generate events on your site
- Verify events appear in real-time
Test Event Code:
ttq.load('YOUR_PIXEL_ID', {
debug: true // Enable debug mode
});
Events Manager
Monitor pixel health:
Ads Manager > Assets > Events:
- Pixel status (active/inactive)
- Events received (last 7/28 days)
- Event breakdown by type
- Top events by volume
- Event quality score
Browser Console Debugging
Test pixel in browser console:
// Check if ttq is loaded
if (typeof ttq !== 'undefined') {
console.log('TikTok Pixel loaded');
console.log('Pixel ID:', ttq._i);
} else {
console.error('TikTok Pixel not found');
}
// Enable debug mode
ttq.instance('YOUR_PIXEL_ID').debug(true);
// Fire test event
ttq.track('CompletePayment', {
value: 1.00,
currency: 'USD',
order_id: 'TEST_' + Date.now()
});
Event Quality Score
Monitor event quality in Events Manager:
Factors affecting score:
- Event match quality (user identifiers)
- Event parameter completeness
- Event deduplication implementation
- Browser vs server-side ratio
Target: 6.0+ for optimal campaign performance
Common Issues
Pixel not loading:
- Verify Pixel ID is correct
- Check network requests in browser DevTools
- Ensure script loads before events fire
- Test without ad blockers
Events not tracking:
- Wait 15-30 minutes for processing
- Verify event name spelling (case-sensitive)
- Check required parameters included
- Review Events Manager for errors
Low match quality:
- Implement advanced matching with hashed identifiers
- Use Events API for server-side tracking
- Include email, phone, external_id
- Pass _ttp cookie value via API
Best Practices
Implementation
- Install pixel on all pages for complete funnel tracking
- Use both Pixel and Events API for maximum data coverage
- Implement advanced matching with user identifiers
- Use GTM for centralized pixel management
- Enable debug mode during testing
Event Strategy
- Track full funnel (ViewContent → AddToCart → CompletePayment)
- Use standard events for best optimization
- Track micro-conversions for remarketing audiences
- Implement video engagement events for content
- Create separate pixels for different business units if needed
Data Quality
- Pass value and currency for all ecommerce events
- Include content_id matching catalog products
- Use event_id for deduplication
- Send order_id for purchase events
- Hash all PII using SHA256
Privacy & Compliance
- Implement consent management for GDPR/CCPA
- Hash PII before sending (email, phone)
- Use TikTok's Limited Data Use flag if needed
- Update privacy policy to disclose TikTok tracking
- Honor user opt-outs via platform controls
Optimization
- Use Value Optimization for ecommerce campaigns
- Optimize to CompletePayment for purchases
- Create lookalike audiences from high-value converters
- Exclude converted users from acquisition campaigns
- Test different attribution windows based on sales cycle
Creative Optimization
- Create vertical video (9:16 ratio) for native experience
- Use first 3 seconds to capture attention
- Test user-generated content style creative
- Add captions for sound-off viewing
- Include clear CTA within video
TikTok Shopping
- Sync product catalog with TikTok
- Match content_id to catalog exactly
- Use TikTok Shop for native checkout
- Implement dynamic ads for retargeting
- Track in-app purchases separately
Mobile App Campaigns
- Integrate TikTok SDK for app events
- Use MMP for attribution and measurement
- Track post-install events for optimization
- Implement deep linking for better UX
- Optimize to in-app purchases not just installs
Testing
- Use TikTok Pixel Helper to verify implementation
- Generate test events in Events Manager
- Verify events within 30 minutes of firing
- Test deduplication with Pixel + Events API
- Monitor Event Quality Score regularly
Reporting
- Break down by placement (In-Feed vs TopView)
- Segment by device and operating system
- Track video engagement metrics alongside conversions
- View click vs view conversions separately
- Export data for custom analysis
Gen Z Marketing
- Optimize for mobile-first consumption
- Keep content authentic and entertaining
- Participate in trends and challenges
- Use influencer partnerships with tracking
- Test live commerce features for direct selling