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.
Troubleshooting
Events Not Appearing in TikTok Events Manager
Events Not Appearing in TikTok Events Manager
If events aren’t showing in TikTok:
- Verify your Pixel ID and Access Token are correct
- Check that your trigger conditions are being met
- Ensure your GA4 event is properly configured to send data to the server
- Verify the server container is receiving events (check Preview mode)
- Make sure the tag is firing in the server container
Error Messages in GTM Console
Error Messages in GTM Console
Common error messages and solutions:
- Invalid Pixel ID: Double-check your Pixel ID and ensure it matches exactly
- Invalid Access Token: Generate a new Access Token in TikTok Events Manager
- Missing Required Fields: Ensure all required parameters are correctly configured
- Invalid Event Name: Verify the event name is one of TikTok’s supported event types
Duplicate Events
Duplicate Events
If you see duplicate events in TikTok Events Manager:
- Check if your deduplication setup is correctly configured
- Ensure both client-side and server-side implementations use the same event_id
- Verify event_id generation is consistent across events
Website Performance Issues
Website Performance Issues
If you notice performance degradation:
- Check if both client-side and server-side tags are firing correctly
- Consider implementing a sampling strategy for high-volume events
- Optimize your GTM container for performance
Frequently Asked Questions
Is server-side GTM the right solution for my business?
Is server-side GTM the right solution for my business?
The answer depends on your current setup:
Situation | Recommendation |
---|---|
GTM users who have TikTok pixel but no Events API | Highly recommend adding Events API via GTM Server Side template |
GTM users with neither TikTok pixel nor Events API | Set up both Pixel and Events API via GTM templates for maximum coverage |
GTM users with Events API but no TikTok pixel | Add TikTok pixel for dual-channel setup and best ad performance |
Non-GTM users | Evaluate Google Tag Manager benefits first before implementing |
Can I use an existing tagging server for Events API?
Can I use an existing tagging server for Events API?
Yes, you can reuse your existing tagging server for TikTok Events API integration. If your GTM Web container already has a Google Tag with server_container_url pointing to the tagging server, you can continue using it.
Just make sure to configure the TikTok Events API tag correctly in your server container.
How can I create a new access token if needed?
How can I create a new access token if needed?
If you need to generate a new token (for example, when switching to a different Pixel ID):
- Navigate to your pixel settings in TikTok Events Manager
- Scroll down to the Access Token section
- Click “Generate Access Token”
- Copy the new token
- Update the Access Token value in your TikTok Events API tag
Do I need to set up event_id for deduplication?
Do I need to set up event_id for deduplication?
Yes, if you’re using both TikTok Pixel (client-side) and Events API (server-side), you need to set up event_id for proper deduplication. This ensures TikTok can match events from both sources and avoid double-counting conversions.
The event_id should be:
- Unique per event occurrence
- Consistent between Pixel and Events API for the same event
- Passed in the same format to both implementations