TikTok ads measure through a pixel and a server-side Events API, with the same ideas as Meta: standard events with parameters, advanced matching with hashed identifiers, and deduplication between browser and server. If you already have a clean dataLayer for GA4 and Meta, adding TikTok is an afternoon's work. This guide covers the GTM setup, the event mapping, and the server-side half.
Step 1: Pixel and Access Token
In TikTok Ads Manager, open Tools, then Events, then Web events, and create a pixel if none exists. Choose manual setup. Copy the Pixel ID. Under the pixel's settings, generate an access token for the Events API and keep it for the server container.
Step 2: Base Pixel in GTM
Add the TikTok Pixel template from the Community Template Gallery. Configure the base tag with the Pixel ID, event type Page View, Advanced Matching enabled with email and phone mapped to your Data Layer Variables, a consent requirement for ad_storage, and the All Pages trigger plus your consent update event.
Raw code equivalent for reference:
<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>
The template is easier to maintain; use the snippet only if you need something the template lacks.
Step 3: Event Mapping
| dataLayer event | TikTok event | Parameters |
|---|---|---|
| view_item | ViewContent | content_id, content_type product, content_name, value, currency |
| add_to_cart | AddToCart | content_id, content_type, value, currency, quantity |
| begin_checkout | InitiateCheckout | contents, value, currency |
| add_payment_info | AddPaymentInfo | value, currency |
| purchase | CompletePayment | contents, value, currency, order id as event ID |
| form_submit_success | SubmitForm | content_name |
| phone_click | Contact | content_name |
| sign_up | CompleteRegistration | |
| search | Search | query |
Create one TikTok event tag per row, triggered by the dataLayer event, with parameters mapped from the same variables your GA4 and Meta tags use. Set the Event ID on each to the transaction ID for purchases and a unique per-submission value for forms.
Step 4: Identify for Advanced Matching
TikTok matches on hashed email, phone and an external ID. Through the template, map them on the base tag and on conversion tags. With raw code:
ttq.identify({
email: {{dlv - user_email}},
phone_number: {{dlv - user_phone}},
external_id: {{dlv - user_id}}
});
The SDK hashes them before sending. Call identify before the conversion event fires, for example on the same trigger with tag sequencing, or on the user data dataLayer push.
Step 5: Capture ttclid
TikTok appends ttclid to landing URLs. The pixel stores it; for server events, store it yourself. Extend the click ID cookie script from the Offline Conversions guide on this site to include ttclid, and pass it to the server with the event or let the server template read the _ttp and ttclid cookies.
Step 6: Events API Through Server-Side GTM
In the server container, add the TikTok Events API template. Configure the Pixel ID and access token. Map event names from your GA4 event names to TikTok names as in the table, set the event ID from event data, include hashed email, phone and external ID, the client IP and user agent, and the ttclid and _ttp values. Trigger it on the events you chose. Add a consent condition on ad_storage.
TikTok deduplicates when the browser pixel and server event share the event ID and event name.
Step 7: Verify
- GTM Preview: each TikTok tag fires once with parameters. Inspect the request in a tag debugger such as the Insighter Debugger extension.
- TikTok Pixel Helper extension: events and parameters shown, no warnings.
- TikTok Events Manager, Test events: browser and server events arrive; duplicates shown as deduplicated.
- The next day, Events Manager shows the events with match status; aim for email and phone present on conversion events.
Common Problems
- Events fire but no attribution.
ttclidmissing on server events or landing pages stripping parameters. - Doubles. Event IDs differ between pixel and server.
- No match on conversions. identify not called before the event, or values unhashed and malformed.
- Learning phase never ends. Optimising for an event with too little volume; move one step up the funnel.
Outcome
TikTok receives the same clean events as GA4 and Meta, from the browser and the server, with identifiers that let it match and deduplicate. Campaign optimisation and reporting work from day one, and adding TikTok did not require touching the site.
