Stape/Documentation

How to configure TikTok Events API Gateway

Important! Before you begin, ensure that TikTok web tracking is already configured on your site, whether it's implemented through a GTM container, embedded directly in the website code, or integrated via a plugin. This setup allows you to use existing web events.

Step-by-step guide to configure TikTok Events API Gateway

Create a TikTok Events API Gateway on Stape

1. Log in to your stape.io account.

2. Open the TikTok Events API Gateway page.

Open the TikTok Events API Gateway page

3. Click Create Gateway.

Click Create Gateway

4. Fill in the required fields:

  • Gateway name. Enter a descriptive name.  
  • Admin email. This email will be used to manage your TikTok Events API Gateway and can differ from your Stape account email. It should be unique for each Gateway. 
  • Servers location. For better performance, select a location closer to your website’s visitors.

Then click Create gateway.

Fill in the required fields

5. Select a subscription plan or click Add card later to activate a 7-day free trial.

Select a subscription plan or click Add card later

6. Wait until the Gateway is verified (the status changes to Running.)

Wait until the Gateway is verified

Connect your Pixel

1. Click Finish TikTok Gateway setup

Click Finish TikTok Gateway setup

2. You will be redirected to the login interface of TikTok Gateway. Log in using your credentials.

Log in to TikTok eAPI Gateway Hub

3. In the Events API Gateway hub, click View details → click Connect Data Source.

Click View details → click Connect Data Source

4. Choose the account and Pixels you’d like to connect and confirm your choices. You will see the added Pixel on your dashboard.

Choose the account and Pixels you’d like to connect

5. (Recommended) Load TikTok js from your subdomain. This will help you increase the protection of your events from ad blockers. 

Click View base code.

Click View base code

Next, follow the instructions on the Install Base Code screen.

Follow the instructions on the Install Base Code screen

6. (Optional) Add new Pixels. You can use a single TikTok Events API Gateway to set up multiple TikTok Pixels. Additionally, Pixels from various TikTok Business Accounts can be connected to the same Events API Gateway, provided you have admin access to all the Pixels. 

To do that, once you’ve configured your TikTok Events API Gateway, add new Pixels through the hub interface by clicking Connect data source.

Connect data source

Configure a custom domain

Using a custom domain in your TikTok Events API Gateway is highly recommended. It can improve measurement performance, allowing you to choose the subdomain for the Pixel's communication with the Events API Gateway. To achieve this, you'll need to update the tenant domain to a subdomain of your website.

1. In your TikTok Events API Gateway Hub, click Settings Set up domain.

Set up domain in your TikTok Events API Gateway Hub

2. On the Choose domain screen, enter the requested info:

  • Prefix - the subdomain of your custom domain.
  • Your domain - your existing domain.

Don’t forget to tick the box next to Before configuring DNS settings… and click Next.

Enter the requested info

3. On the Configure DNS screen, you will be provided with DNS records that you should add to your DNS provider.

DNS records that you should add to your DNS provider

Here’s how to add these records to your DNS provider, using Cloudflare as an example: 

3.1. Visit your Cloudflare profile → open the DNS tab in the side menu → open the Records screen → click Add record.

Adding DNS records in Cloudflare

3.2. Enter the DNS records from TikTok Events API Gateway Hub: 

  • Type - copy the Type parameter, usually CNAME.
  • Name - copy the Record name parameter.
  • Target - copy the Value parameter.
  • Proxy status - make sure to toggle this OFF.

Click Save.

Enter the DNS records 

Next, wait until the Waiting status in the TikTok Events API Gateway Hub changes. 

Waiting status in the TikTok Events API Gateway Hub

Custom subdomain is not verified - what to do

Domain verification can take up to 72 hours, but it usually happens within 30-60 minutes if your DNS records are correct. If it takes more time for you, there may be a problem with your configurations.

1. Open the Google Admin Toolbox service called Dig: https://toolbox.googleapps.com/apps/dig/

2. Enter the subdomain you created for Google Tag Gateway (without https:// or any extra characters). Then, select the record type you want to check.

Google Admin Toolbox service called Dig

Using this tool, check your DNS records. There are three main reasons why a subdomain may not verified:

  • Missing DNS records - make sure that you added all the records specified in your Gateway on Stape.
  • Incorrect DNS records - if all entries exist, check that their values match those in your Gateway.
  • Extra DNS records - see that there are no extra DNS records for your TikTok Events API Gateway subdomain, only those provided by Stape. Extra records can interfere with domain verification, so you should remove them.
Three main reasons why a subdomain may not verified

Testing TikTok Events API Gateway

TikTok Events API Gateway uses web events to route them via the server. 

Within 30 minutes of connecting your Pixel to the TikTok Events API Gateway hub, you should notice that the event count is no longer zero, and you should also see the names of the events that have been received. 

Testing TikTok Events API Gateway

You can also verify that events are sent correctly to the TikTok Events APIG hub by checking the browser console:

  1. Open your browser Developer Tools Network tab and reload the webpage.
  2. Check that events were sent to your TikTok Events API Gateway URL.
TikTok Events APIG hub events in browser console
Can’t find what you are looking for?