Skip to content Skip to sidebar Skip to footer

Installing the TikTok Event API

Table of Contents

There is a problem that no one tells you about when you start advertising on TikTok: the pixel only gives you half of the data. The other half disappears silenced by ad blockers, browsers in private mode and iOS restrictions. And if you don't see that half, you're optimizing your campaigns with incomplete information. Before this article is over, you'll understand exactly what the TikTok Event API is, why you need it, and how to set it up step-by-step. And if at any point you decide you'd rather have someone else do it right from the start, I'll explain how we do it at the end at Analytic Pixel Pro.

What is the TikTok event API and why does it exist?

The TikTok pixel is a code that is installed on your website and sends information to TikTok from the user's browser. When someone visits your site or buys a product, the pixel records it and sends it to TikTok.

The problem is that the journey from the browser to TikTok can be interrupted:

  • Ad blockers block it.
  • Safari and Firefox limit third-party cookies.
  • Some users have privacy settings that prevent tracking.
  • iOS 14+ restrictions reduce the attribution window.

The result is that TikTok can miss between 20% and 40% of actual conversions, depending on your audience. And with incomplete data, the algorithm optimizes poorly, your campaigns underperform and you invest more to get less.

The TikTok Event API (also called Events API or TikTok CAPI) is the solution. Instead of sending the data from the user's browser, you send it from your server directly to the TikTok server. The trip is much shorter, safer and cannot be blocked by any browser extension.

When do you need the TikTok event API?

If you invest in TikTok Ads and you care about attribution, you need it all the time. But there are situations where it becomes especially critical:

  • You have an eCommerce store and you want TikTok to see all your purchases, not just the ones not blocked by the browser.
  • You manage performance campaigns and you need the algorithm to have the right data to optimize well.
  • Your audience is technological and are likely to use ad blockers or Safari with ITP enabled.
  • You invest in scaling and you need reliable data to know which campaigns really work.

Simply put: if the pixel is your only source of data, you're flying blind.

The two components you need before installing anything

Before touching any configuration, you need to be clear about which parts come into play.

The TikTok pixel (client side)

The pixel is still required even if you use the API. It works in the browser and captures data such as the ttclid (the TikTok click identifier) and the cookie _ttp, which are used to identify the user within the platform. Without this data, deduplication does not work properly.

The event API (server side)

The API sends the same events as the pixel, but from your server. You need a Access Token to authenticate with TikTok and your Pixel ID to know to which pixel to associate the events.

The key is that both systems must work together, not separately. TikTok uses the Event ID to deduplicate: if you receive the same event from the browser and from the server with the same ID, it is counted only once. If you don't configure deduplication right, you will inflate the data.

How to install the TikTok event API step by step

There are several ways to implement the API. I will explain the most professional and scalable one: using Google Tag Manager Server-Side (sGTM). This is the one I recommend for any business that already has a volume of campaigns.

Step 1: Generate the Access Token in TikTok Ads Manager

  1. Enter in TikTok Ads Manager.
  2. Go to Assets → Events → Web Events.
  3. Select your pixel.
  4. Click on Settings and look for the section Access Token Generation.
  5. Click on Generate Access Token and copy it. You will need it later.

This token is like the key that gives your server permission to talk to TikTok. Keep it in a safe place.

Step 2: Copy your Pixel ID

In the same pixel configuration screen, you will see the Pixel ID. Copy it too. It is the identifier that tells TikTok to which pixel the events you send belong.

Step 3: Configure your GTM server-side container

For the API to work, you need a server container in Google Tag Manager. There are several ways to set it up:

  • Google Cloud Run (native Google option).
  • Stape o TAGGRS (managed solutions that simplify the infrastructure).

If you already have a running server container for GA4 or Meta CAPI, the process is added on top of the same infrastructure.

Step 4: Add the TikTok Events API tag in GTM Server

  1. Log in to your GTM server container.
  2. Go to Tags → New → Tag Configuration.
  3. Search in the Community Template Gallery the label TikTok Events API (Official).
  4. Add your Access Token and your Pixel ID in the corresponding fields.
  5. If you are going to test, add the Test Event Code (you can find it in TikTok Events Manager under the tab Test Events). Remember to delete it before publishing in production.

Step 5: Map event parameters

This is the most important part and where most mistakes are made. You need to make sure that the events you send to the server contain the correct information:

  • Name of the event: Purchase, AddToCart, ViewContent, CompleteRegistration, etc.
  • Event ID: A unique identifier per event. This is what TikTok uses to deduplicate. It must be the same as the one sent by the browser pixel.
  • User data: The user's IP address: email, phone, user's IP, user agent. TikTok automatically hashes them in SHA-256.
  • Product parameters: value, currency, content_id, content_type.
  • ttclid and _ttp: TikTok click identifier and cookie. They are essential for attribution.

Step 6: Configure the trigger

The trigger defines when the TikTok tag is fired. It is usually configured to trigger on GA4 events that already come from your web container. For example, when GA4 logs a purchase, The same event arrives to the server and from there you forward it to TikTok.

Step 7: Configure deduplication

In order for TikTok not to count the same event twice (once from the pixel and once from the API), you have to pass the same event to TikTok. Event ID on both sides:

  • In the web pixel: generates a unique ID (e.g, purchase_12345_timestamp) and spend it in the field event_id of the pixel.
  • In the server: Use the same ID in the TikTok Events API tag.

If you don't do this, TikTok may duplicate your conversions and your data will be incorrect.

Step 8: Test before publishing

  1. Use the Preview mode GTM to verify that the label is triggered correctly.
  2. Go to TikTok Events Manager → Test Events and check that the server events appear in the tab Test Server Events.
  3. Verify that the Event Match Quality (EMQ) is high. This indicator measures how well TikTok can relate your events to real users. The higher, the better the attribution.

Step 9: Publish

Once you have verified that everything is working, publish your server container. From that moment on, you will start to recover the conversions that the pixel lost.

Most common mistakes when installing the TikTok API

I have seen these implementations many times and always come up with the same bugs:

Do not configure deduplication. If you send the same event from the browser and from the server without an Event ID to link them, TikTok counts them as two different conversions. Your data is inflated and the algorithm optimizes on lies.

Forget about ttclid and _ttp. These values are what allow TikTok to attribute the conversion to the correct ad click. If you don't send them, you lose attribution.

Failure to hash user data correctly. TikTok expects the email and phone to come in lowercase SHA-256. If you send them in plain text or uppercase, the matching fails.

Publish with the Test Event Code active. If you forget to delete it before publishing, the actual data are marked as tests and may not be processed correctly.

Use the server container for everything without the web pixel. The API and the pixel are complementary. You need both for deduplication to work and to capture the ttclid.

How much the data is improved with the event API

The actual impact depends on your audience and your industry, but in general you can expect it:

  • Recovery of between 15% and 40% of events that the pixel missed.
  • Improvement in the Event Match Quality Score, which means better attribution.
  • More efficient TikTok algorithm, because it has more real data to optimize.
  • Larger custom audiences, because they are built with more signals.

This data translates directly into a higher ROAS when you scale investment. Not because you have spent more, but because the algorithm makes better decisions.

Privacy and GDPR compliance

TikTok's event API does not exempt you from GDPR compliance. In fact, when handling user data on the server, you have to ensure:

  • Only send data of users who have given their consent.. The server must know if the user has accepted the marketing cookies before sending their data to TikTok.
  • Anonymize or not to send certain data if the user has not given explicit consent.
  • Documenting data flow as part of your record of treatment activities.

A well-configured consent management system (CMP) must control what data travels to the server and under what conditions.

Why it makes sense for Analytic Pixel Pro to set it up

Installing the TikTok Event API is not complicated if you already have experience with GTM server-side, but there are many details where a bad configuration can cost you data or generate duplications that distort your whole analysis.

At Analytic Pixel Pro we implement the TikTok API integrated within a tracking ecosystem that includes:

  • GTM web and server correctly connected.
  • Deduplication configured so that no event is counted twice.
  • Integration with consent for the tracking to be GDPR compliant.
  • Event Match Quality Verification before the implementation is considered successful.
  • Testing in test environment before going into production.

If you already have Meta CAPI or GA4 running on a server, adding TikTok Events API on top of the same infrastructure is much more efficient than setting it up separately.

The goal is that when you scale your investment in TikTok, you do so knowing that every euro you invest is being measured correctly. You can contact us here to review your current setup and see what data you are losing.

Frequently Asked Questions about the TikTok Event API

Do I need the API if I already have the pixel installed? Yes, the pixel only works from the browser and is subject to locks. The API retrieves the events that the pixel misses. They are complementary, not alternative.

Can I install the API without Google Tag Manager server? Yes, TikTok offers direct integration via API and there are also solutions like Stape that simplify the infrastructure. But for businesses already using GTM for other platforms, the server container is the cleanest and most scalable option.

How long does it take to see the impact? Once the implementation is published, TikTok starts receiving server events immediately. The algorithm can take 24-72 hours to process the new volume and adjust the optimization of the campaigns.

Does the API work for mobile applications? TikTok has an Events API for apps (version 2.0) that works in a similar way. In this article I have focused on the web implementation, which is the most common for eCommerce and businesses with a web presence.

What is the Event Match Quality Score? It is a score that TikTok assigns to each event to indicate how well you can relate it to a real TikTok user. The higher it is (scale from 1 to 10), the better attribution you get. It is improved by sending more user signals: email, phone, IP, ttclid and _ttp.