← All Guides

TikTok Pixel and Events API Setup with Google Tag Manager: Standard Events, Advanced Matching and Server-Side Deduplication

How to install TikTok Pixel through GTM, fire the right standard events with parameters from your existing dataLayer, add Advanced Matching, send the same events server-side through the Events API from server-side GTM with deduplication, and verify in TikTok Events Manager.

Atiqul Islam
Written by Atiqul Islam

Tracking & analytics specialist. 278+ GTM, GA4 and server-side tracking projects for clients in the US, UK and Australia.

Rather not do this yourself? I set this up for clients every week. Free 15-minute audit, no obligation.

Book a Free Audit

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

  1. GTM Preview: each TikTok tag fires once with parameters. Inspect the request in a tag debugger such as the Insighter Debugger extension.
  2. TikTok Pixel Helper extension: events and parameters shown, no warnings.
  3. TikTok Events Manager, Test events: browser and server events arrive; duplicates shown as deduplicated.
  4. The next day, Events Manager shows the events with match status; aim for email and phone present on conversion events.

Common Problems

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.

Frequently Asked Questions

Can I reuse my GA4 and Meta dataLayer for TikTok?

Yes. TikTok's standard events map closely to Meta's: ViewContent, AddToCart, InitiateCheckout, CompletePayment, SubmitForm, Contact, CompleteRegistration. One dataLayer event triggers one tag per platform.

What is the TikTok Events API?

TikTok's server-side endpoint, equivalent to Meta's Conversions API. You send events from a server with an event ID matching the pixel event, and TikTok deduplicates. Server-side GTM has a template for it.

Which event should I optimise for?

The deepest event with enough volume: CompletePayment for ecommerce, SubmitForm or Contact for lead generation. TikTok's learning phase needs a steady weekly flow, so lower-funnel events on small accounts may need to start at AddToCart or ViewContent.

Does TikTok have an equivalent of Event Match Quality?

TikTok Events Manager shows a match status per event based on the identifiers sent: hashed email and phone, external ID, and the ttclid click ID and ttp cookie. Send all of them for the best match.

Is a ttclid required?

It is the click ID TikTok appends to landing URLs. Capture it into a first-party cookie on arrival and send it with server events; the pixel handles it in the browser automatically.

Want This Done Right the First Time?

Book a free 15-minute audit call. I'll review your setup, show you what is broken, and tell you exactly what it takes to fix it.

Chat Now