> For the complete documentation index, see [llms.txt](https://docs.adpage.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.adpage.io/integrations-marketingtools/tiktok-ads.md).

# TikTok Ads

How to set up TikTok Ads tracking through the TikTok Events API

This guide shows you how to configure the TikTok Events API in your Google Tag Manager server container, step by step.&#x20;

{% hint style="warning" %}
**This article covers a server-side only setup.** All TikTok events are sent from your server container to the Events API, there is no TikTok Pixel firing in the browser. You can also run TikTok Ads **client-side and server-side at the same time**, with event deduplication based on a shared event ID. We describe that setup in [Setting up client-side TikTok Ads tracking with deduplication](/integrations-marketingtools/tiktok-ads/setting-up-client-side-tiktok-ads-tracking-with-deduplication.md).
{% endhint %}

### Before you start

Make sure you have:

* [ ] A working GTM server container that receives events (usually via your Google Tag / GA4 client).
* [ ] Your **TikTok Pixel ID** and **API Access Token**. See [How to find your TikTok Pixel ID and Access Token](/integrations-marketingtools/tiktok-ads/where-to-find-the-tiktok-pixel-id-and-the-tiktok-api-token.md).

### Step 1: Add the tag template

1. Open your GTM server container and go to **Templates**.
2. Under **Tag Templates**, click **Search Gallery**.
3. Search for the **TikTok Events API** tag template and add it to your workspace.

<figure><img src="https://1274044937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA65KwL1NwewlJbtCXsXd%2Fuploads%2FCp6SEiMdzNl6qUWoZM3t%2Fimage.png?alt=media&amp;token=96dcc084-6ba6-4125-80bb-7d7b46f93c09" alt=""><figcaption></figcaption></figure>

### Step 2: Create the Events API tag

1. Go to **Tags** and create a new tag. Choose **TikTok Events API** as the tag configuration.
2. Under **Event Name Setup Method**, choose **Inherit from client**. The tag will then use the event names of the incoming GA4 requests.
3. Fill in your Access Token in the **Access Token** field.
4. Fill in your TikTok Pixel ID in the **TikTok Pixel ID** field.

{% hint style="info" %}
Inheriting the event name means TikTok receives your GA4 event names, such as `purchase` and `add_to_cart`. Those arrive as custom events. TikTok's algorithm works better with its own standard event names, and you need standard events if you later add the TikTok Pixel with deduplication.
{% endhint %}

<figure><img src="https://1274044937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA65KwL1NwewlJbtCXsXd%2Fuploads%2F9lIR2x1wCkMX0JwlTdSn%2Fimage.png?alt=media&amp;token=d0a1c1ed-56d1-4bb2-ae36-1693a396480d" alt=""><figcaption></figcaption></figure>

5. Set the four checkboxes as follows:

| Option                                           | Recommended |
| ------------------------------------------------ | ----------- |
| Generate Browser ID (`_ttp`) cookie if not exist | Disabled    |
| Enable Event Enhancement                         | Enabled     |
| Override Cookies Settings                        | Disabled    |
| Use Optimistic Scenario                          | Disabled    |

**Generate Browser ID (\_ttp) cookie if not exist**

The \_ttp cookie holds the browser ID. In a setup with a TikTok Pixel, the Pixel creates this cookie itself, so the option is redundant there. **Recommendation: leave this disabled.** A \_ttp value your own server invents is not an identifier TikTok issues or recognises. TikTok cannot tie it to a person on its own. All it can do is group events that came from the same browser, and that only works if the cookie is reliably written to your tracking domain and returned on every following request.

**Enable Event Enhancement**

This option lets the tag store user data in a separate HttpOnly cookie (gtmeec-tt) on your own domain. When a later event arrives without user data the tag enriches that event with the stored data.**Recommendation: enable this.** It raises your event match quality, which improves attribution and TikTok's ability to optimise your campaigns.&#x20;

{% hint style="info" %}
Do consider your privacy documentation: the tag stores personal data (hashed) in a cookie on your domain, so make sure this is covered in your cookie policy and that the tag only fires with marketing consent.
{% endhint %}

**Override Cookies Settings**

The tag writes three cookies on your domain: the click ID, the browser ID and the event enhancement cookie. This option lets you override the **domain** and the **SameSite** attribute all three are written with. By default the domain is determined automatically, based on the page URL of the incoming event, with the request headers as a fallback. That is correct for a normal single-domain setup. Only enable it if the automatic behaviour is wrong for your situation, for example when you need the cookies set on your top-level domain because you track across subdomains, or when your SameSite policy has to differ from the default.&#x20;

**Use Optimistic Scenario**

Normally the tag waits for TikTok's API to confirm that the event was received before reporting back to GTM. With this option enabled, the tag reports success immediately, without waiting for a response. **Recommendation: leave this disabled.** You lose your only view of whether events actually arrive, which makes tracking problems very hard to spot.&#x20;

### Step 3: Add a trigger

1. Click **Triggers** under the tag configuration, then click the blue plus icon in the top right to create a new trigger.
2. Choose the grey **Custom** option as the trigger configuration.
3. Select **Some Events** to add conditions. Add your condition. Common options are:

* **Based on specific event names**
  * `{{Event Name}}` matches RegEx `eventname|eventname`
    * Always include `page_view` as the first event name.&#x20;
* **Without a condition**, if you want to send every GA4 event to the Conversions API
  * `{{Client Name}}` equals `GA4`

<figure><img src="https://1274044937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA65KwL1NwewlJbtCXsXd%2Fuploads%2F09nuRstySRTL2EgBvnGH%2Fimage.png?alt=media&amp;token=8035df45-7ded-40d4-ac60-102290b992b0" alt=""><figcaption></figcaption></figure>

4. Save the trigger and the tag.

### Step 4: Test

Use the server container preview mode to check that the Facebook Conversion API tag fires on incoming events.

For a more thorough check, add a **Test ID** to the tag and open the Test Events tab in TikTok Ads Manager. Your events should appear with **Server** listed as the source. Remove the Test ID again once you are done testing.

### Optional: Add or override event parameters

By default, the tag builds its payload from the incoming event on its own. It reads the parameters your web container sends to the server container and maps the ones it recognises to their TikTok equivalents. For most setups that is enough.

You can override that mapping, or add parameters the tag does not pick up by itself. Open your TikTok Events API tag and expand the sections below the main settings:

* **Server Event Data Override** — for event-level fields, such as the event ID, referrer, timestamp and URL.
* **User Data** — for identifying parameters, including email, phone number, external ID, click ID and browser ID.
* **Properties** — for the commercial details of the event, such as value, currency, content and query.

Each section works the same way: you add a property, choose which field you want to fill, and give it a value. That value is normally a variable pointing at a parameter in the incoming event. Anything you enter manually takes precedence over what the tag mapped automatically.

There are two reasons to do this:

* **The parameter arrives, but the tag does not map it.** Your web container may send a value under a name the tag does not recognise, or in a structure it cannot read. Pointing the field at the right parameter yourself gets it into the payload.
* **The parameter is wrong or missing.** If the automatic mapping produces a value you do not want to send, an override replaces it.

Which parameters are available to you depends entirely on what your GA4 event tags send from the web container. There is no universal list. Open the server container preview mode, look at an incoming request, and work from the parameters you actually see there.

Two things to keep in mind. The tag hashes user data automatically, so pass values in plain text and do not hash them yourself first. And only map parameters you have a legal basis to send: anything you add here goes to TikTok, so it needs to be covered by your consent setup and your privacy statement.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.adpage.io/integrations-marketingtools/tiktok-ads.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
