TikTok Events with sGTM
Complete guide to setting up TikTok Events API through server-side Google Tag Manager for enhanced conversion tracking and improved ad performance
Overview
Server-side Google Tag Manager (sGTM) implementation for TikTok Events API allows you to send conversion events directly from your server to TikTok Ads. This setup offers several advantages over client-side tracking, including improved data reliability, better performance, and reduced impact from ad blockers.
This guide walks you through the complete process of setting up TikTok Events API through server-side Google Tag Manager, from creating a pixel to testing and verification.
The recommended approach is to implement both TikTok Pixel (client-side) and Events API (server-side) simultaneously. This dual-channel implementation maximizes event coverage and provides redundancy, ensuring your campaign performance remains protected even if one channel experiences issues.
Prerequisites
Before you begin this integration, ensure you have:
- A functioning web & server container installed on your website
- A server container created in your GTM account
- A frontend tag (Google Analytics 4) sending events to your tagging server
- Access to TikTok Ads Manager with permissions to access Events Manager
This implementation requires Google Tag Manager knowledge and appropriate access permissions. Make sure you have the necessary expertise or consult with a developer before proceeding.
Implementation Steps
Creating a TikTok Pixel
If you already have a TikTok pixel, you can skip to the next section. Otherwise, follow these steps to create a new pixel:
Access TikTok Ads Manager
Go to TikTok Ads Manager and log in to your account.
Navigate to Events Manager
Hover over “Tools” in the navigation bar, find “Management,” and click on “Events.”
Set Up Web Events
- Click on the “Manage” button under “Web Events”
- Click “Setup Web Events”
- Enter a pixel name
- Select “Events API” as the implementation method
- Click “Next”
Choose Integration Method
- Select “Automatically Set Up Web Events via Partner Platforms”
- Click “Next”
- Choose “Google Tag Manager Server-side”
- Click “Next”
Save Pixel Information
Your new pixel is now created. Make note of the Pixel ID displayed on the screen.
Getting Pixel ID & Events API Access Token
To configure the TikTok Events API template, you’ll need your Pixel ID and an API Access Token:
Access Pixel Settings
Navigate to Tools > Events > Web Events in TikTok Ads Manager, select your pixel, and go to the Settings tab.
Copy Pixel ID
At the top of the Settings page, you’ll find your Pixel ID. Copy and save this value.
Generate Access Token
- Scroll down to find the “Access Token” section
- Click “Generate Access Token”
- Copy and save the token that appears
Your credentials should look similar to these examples:
- Pixel ID:
CIB1R6JC77UCDSLJS0OG
- Access Token:
00c350fde1xxxxxxxxxxxxxxxxxxxxxxxx1991af
Setting Up Server-Side Google Tag Manager
Install the TikTok Template
- In your GTM server container, navigate to Tags
- Click “New” to create a new tag
- Click the tag configuration area to select a tag type
- Search for “TikTok Events API (Official)” in the Community Template Gallery
- Click “Add to workspace” to install it
The template can only be applied to a Server container. Make sure your container type is set to “Server” before proceeding.
Configure the Event Settings
- Enter your Pixel ID and Access Token in their respective fields
You can create GTM variables for the Pixel ID and Access Token to reuse them across multiple tags. Click the ”+” sign next to each field to create or select variables.
- Select the Event type you want this tag to track
- The event should match the trigger you’ll associate with this tag
- Refer to TikTok’s Supported Pixel events for available event types
Set Up Advanced Matching
Advanced matching helps improve conversion tracking accuracy by sending hashed user identifiers:
- Configure Email, Phone, and External ID fields using GTM variables
- All identifiers are automatically hashed with SHA256 before being sent to TikTok
Implementing advanced matching early in the user journey significantly improves match quality and campaign performance.
Choose one of the following options to pass user information:
- Extract from Common Event Schema: Use this when values are available in the GA4 common event schema
- Use Custom Variables: Select specific variables for each field when data is available from other sources
Configure E-commerce Data
If you’re tracking product or purchase events, configure the e-commerce data section:
- Select “Use Google Analytics Ecommerce Data Layer”
- This automatically captures product data from your GA4 ecommerce implementation
- Ensure your website is properly pushing ecommerce data to the data layer
- Select “Use Google Analytics Ecommerce Data Layer”
- This automatically captures product data from your GA4 ecommerce implementation
- Ensure your website is properly pushing ecommerce data to the data layer
Choose one of the following options based on your needs:
Single Content: For events associated with a single product
- Configure individual fields using variables
- Include product details like price, content_id, content_name, etc.
Multiple Contents: For events with multiple products (like cart or purchase events)
- Provide a JSON-encoded string of products
- Format should follow TikTok’s required schema
Order Info Only: For basic purchase tracking
- Only configure value and currency fields
- Use this when detailed product information is unavailable
Set Up Deduplication
If you’re implementing both TikTok Pixel (client-side) and Events API (server-side), configure event deduplication:
- Select the appropriate event_id variable
- Ensure both Pixel and Events API implementations use the same event_id
Deduplication is critical when using both Pixel and Events API to avoid double-counting conversions and ensure accurate campaign reporting.
Configure Additional Settings
The template automatically collects server information like IP address and user agent. You can leave this section blank unless you need to override specific fields.
Set Up Trigger
- Click the Triggering area to select or create a trigger
- Configure a trigger that fires when the appropriate event is received
- For example, to track purchase events, create a trigger that activates when a purchase event is detected
- Click “Save” to complete the tag setup
Testing and Verification
Use Preview Mode
- Click “Preview” in your server container
- Trigger test events from your website
- Monitor the preview console to verify the Events API calls
- Look for a response containing
{"code": 0, "message": "OK"}
to confirm success
Use TikTok Test Events Tool
- In TikTok Events Manager, select your pixel
- Go to the “Test Events” tab
- Copy the test event code from Step 2 of the Test Server Events section
- Add this code to your TikTok Events API tag in the “Test Event Code” field
- Save the changes and trigger test events
- Check the Event Activity section to verify events are being received
Remember to remove the test event code after testing is complete before moving to production.