Set up Tiktok Tags on your sGTM container
The TikTok API is a server-side integration that allows you to send website or app events directly from your server to the TikTok server. It works in much the same way as the TikTok Pixel. You can use the TikTok API to send conversion events, collect custom audiences, create dynamic product ads, or optimize campaigns. In the steps below, we will only use TikTok Server events (no TikTok Pixel). Additionally, we will listen to the GA4 events.
Open your GTM web container
Navigate to Templates
Within Tagtemplates, search for "Tiktok Pixel"
Add this template to your workspace
Navigate to variables.
Create a new User-Defined Variable and choose "Constant" as variable type
Input your tiktok pixel ID as value and save as "Tiktok Pixel ID"
Navigate to tags
Create a new Tag and select Tiktok Pixel Id as Tagconfig
In the input fields ‘TikTok Pixel ID’ and ‘Access Token’, enter your Pixel ID variable and your API Token variable.
For the event name type under ‘Event Name Setup Method’, select ‘Inherit from client’.
Select ‘Generate _ttp cookie if not exist’.
Select the trigger. Then click on the blue plus sign in the top right corner to create a new trigger.
For the trigger type, select "custom"
Select ‘Some events’.
In the left dropdown menu, select ‘Client Name’. In the middle dropdown menu, select ‘equals’. In the right input field, enter “GA4”.
17 Add an extra condition by clicking the blue plus sign.
In the left dropdown menu, select ‘Event Name’. In the middle dropdown menu, select ‘matches RegEx’. In the right input field, enter all your standard event names that you have set up on the web container, separated by a vertical bar (|).
Name this trigger ‘TikTok Trigger’ and save it.
Name the tag ‘TikTok - Inherit from Client’ and save the tag.
Create a new tag
Select your TikTok Events API template as the tag configuration.
Enter your TikTok API Token and Pixel ID variables in the appropriate fields.
For Event Name Setup Method, choose ‘Standard’ and then select ‘Complete Payment’ from the dropdown menu.
Select ‘Generate _ttp cookie if not exist’.
Now click on Triggers. Then click the blue plus sign in the top right corner to create a new trigger.
For the trigger configuration select "Custom"
Select ‘Some events’.
In the left dropdown menu, select ‘Client Name’. In the middle dropdown menu, select ‘equals’. In the right input field, enter “GA4”.
Add an extra condition by clicking the blue plus sign.
In the left dropdown menu, select ‘Event Name’. In the middle dropdown menu, select ‘equals’. In the right input field, enter “purchase”.
Name the trigger ‘TikTok Trigger - purchase’ and save the trigger.
Name the tag ‘TikTok - purchase’ and save the tag.
Create a new Tag.
Select your TikTok Events API template as the tag configuration.
Enter your TikTok API Token and Pixel ID variables in the appropriate fields.
For Event Name Setup Method, choose ‘Standard’ and then select ‘Click Button’ from the dropdown menu.
Select ‘Generate _ttp cookie if not exist’.
Now click on Triggers. Then click the blue plus sign in the top right corner to create a new trigger.
For the trigger configuration select "Custom"
Select ‘Some events’.
In the left dropdown menu, select ‘Client Name’. In the middle dropdown menu, select ‘equals’. In the right input field, enter “GA4”.
Add an extra condition by clicking the blue plus sign.
Name the trigger ‘TikTok Trigger - click button’ and save the trigger.
Name the tag ‘TikTok - click button’ and save the tag.
Open your GTM web container
Navigate to Templates
Within Tagtemplates, search for "Tiktok Pixel"
Add this template to your workspace
Navigate to variables.
Create a new User-Defined Variable and choose "Constant" as variable type
Input your tiktok pixel ID as value and save as "Tiktok Pixel ID"
Navigate to tags
Create a new Tag and select Tiktok Pixel Id as Tagconfig
In the input fields ‘TikTok Pixel ID’ and ‘Access Token’, enter your Pixel ID variable and your API Token variable.
For the event name type under ‘Event Name Setup Method’, select ‘Inherit from client’.
Select ‘Generate _ttp cookie if not exist’.
Select the trigger. Then click on the blue plus sign in the top right corner to create a new trigger.
For the trigger type, select "custom"
Select ‘Some events’.
In the left dropdown menu, select ‘Client Name’. In the middle dropdown menu, select ‘equals’. In the right input field, enter “GA4”.
17 Add an extra condition by clicking the blue plus sign.
In the left dropdown menu, select ‘Event Name’. In the middle dropdown menu, select ‘matches RegEx’. In the right input field, enter all your standard event names that you have set up on the web container, separated by a vertical bar (|).
Name this trigger ‘TikTok Trigger’ and save it.
Name the tag ‘TikTok - Inherit from Client’ and save the tag.
purchase / Complete Payment
Create a new tag
Select your TikTok Events API template as the tag configuration.
Enter your TikTok API Token and Pixel ID variables in the appropriate fields.
For Event Name Setup Method, choose ‘Standard’ and then select ‘Complete Payment’ from the dropdown menu.
Select ‘Generate _ttp cookie if not exist’.
Now click on Triggers. Then click the blue plus sign in the top right corner to create a new trigger.
For the trigger configuration select "Custom"
Select ‘Some events’.
In the left dropdown menu, select ‘Client Name’. In the middle dropdown menu, select ‘equals’. In the right input field, enter “GA4”.
Add an extra condition by clicking the blue plus sign.
In the left dropdown menu, select ‘Event Name’. In the middle dropdown menu, select ‘equals’. In the right input field, enter “purchase”.
Name the trigger ‘TikTok Trigger - purchase’ and save the trigger.
Name the tag ‘TikTok - purchase’ and save the tag.
Button Click
Create a new Tag.
Select your TikTok Events API template as the tag configuration.
Enter your TikTok API Token and Pixel ID variables in the appropriate fields.
For Event Name Setup Method, choose ‘Standard’ and then select ‘Click Button’ from the dropdown menu.
Select ‘Generate _ttp cookie if not exist’.
Now click on Triggers. Then click the blue plus sign in the top right corner to create a new trigger.
For the trigger configuration select "Custom"
Select ‘Some events’.
In the left dropdown menu, select ‘Client Name’. In the middle dropdown menu, select ‘equals’. In the right input field, enter “GA4”.
Add an extra condition by clicking the blue plus sign.
Name the trigger ‘TikTok Trigger - click button’ and save the trigger.
Name the tag ‘TikTok - click button’ and save the tag.
Updated on: 16/08/2024
Thank you!