Did you know that TikTok’s advertising revenue is projected to surpass $15 billion by 2024? This staggering statistic highlights the platform’s potential for ecommerce businesses looking to expand their reach and drive conversions. However, accurately tracking TikTok ad campaigns and conversions within a Magento store can be challenging. Fortunately, the Magento TikTok Events API combined with Google Tag Manager (GTM) Server-Side Tagging offers a seamless solution for enhanced data transfer and tracking capabilities.

By integrating these tools, Magento store owners can improve their ROI, enhance targeting, and optimise data-driven decisions. Additionally, the Scommerce Mage Magento 2 GA4 Google Tag Manager extension simplifies this integration process, making it a must-have tool for any ecommerce business leveraging TikTok ads.

Understanding TikTok Events API

What is TikTok Events API?

The TikTok Events API is designed to track user interactions on your website originating from TikTok ads. By capturing valuable data, it helps businesses understand user behaviour and optimise their marketing strategies effectively.

Benefits of Using TikTok Events API

Using the TikTok Events API offers several advantages, including:

  • Accurate Conversion Tracking: Understand which ads drive conversions.
  • Audience Building: Create custom audiences for retargeting.
  • Enhanced Retargeting: Deliver personalised ads based on user interactions.

Prerequisites

  • GA4 data layers and GTM client side implementation:- Our GTM GA4 extension automatically implements this for you.
  • Stape.io account with the server container setup:- check the section below for this setup.
  • GTM server container
  • Events API enabled Tiktok Ads account

Setup Tiktok Events API

Please follow the steps below to setup Tiktok Events API in Tiktok Ads:-

  • Go to Tiktok Ads and navigate to Events Manager.
  • Click on continue setup to setup Tiktok Events API and follow the steps provided.
  • In the implement Events API setup step click on “Generate Access Token” and save this token which we will use later in the setup.
  • Finally finish the setup

Required and Optional Parameters for TikTok Events API

To set up your TikTok Events API, you will need to understand the required and optional parameters. You can find detailed information in the official TikTok Events API documentation.

Parameter Required/Optional Description
event Required The type of event (e.g., PageView, Purchase).
timestamp Required The time when the event occurred.
user_data Required Information about the user (e.g., email, phone).
event_source_url Optional The URL where the event took place.
user_agent Optional The user agent string from the user’s browser.
ip_address Optional The IP address of the user.
custom_data Optional Any additional data you want to pass with the event.

GTM Server-Side

Why Server-Side Tagging?

Server-side tagging offers several benefits, such as improved data security, enhanced website performance, and greater data accuracy. It allows you to manage tags more efficiently and reduces the risk of data loss.

Creating a GTM Server Container

  1. Log into GTM: Access your Google Tag Manager account.
  2. Create a New Container: Select “Create Container” and choose “Server” as the container type.
  3. Configure the Server Container: Follow the prompts to set up your server container.

Connecting Magento to GTM Server

To connect your Magento store to the GTM server container, use the Scommerce Mage Blog. This blog simplifies the process to setup server side container using Stape.io, allowing you to integrate Magento with GTM effortlessly.

Create Tiktok Tag in GTM Client Side Container

Since we do not have a dedicated Tiktok client in GTM server side container we will have to use the GA4 client to get the data from the data layers. GA4 client only captures GA4 events so will have to create an unique GA4 tiktok event that will contain all the required parameters to fire the Serverside Magento Tiktok Events API tag. Let us set up this tag, please check the tag details below:-

  • Tag Name:- GA4-Tiktok-Conversion
  • Tag Type:- Google Analytics: GA4 event
  • MeasurementID :- {{GA4 Measurement ID}} (Add variable containing GA4 measurement ID)
  • Event Name:- tiktok_conversion
  • Event Settings Variable:- {{Google Tag Event Settings}} ( Add variable containing event settings for GA4)
  • Event Parameters
    • conversion_hashed_phone:- (Add variable containing hashed phone from data layers)
    • conversion_hashed_email:- (Add variable containing hashed email from data layers)
    • event_id:- Add a variable generates a unique id for each event
    • ttiktok_click_id:- Use the variable that captures tiktok click ID passed with the URL
    • currency:- (Add the variable containing currency)
    • revenue:- (Add variable containing conversion value from data layers)
    • transaction_id:- (Add variable containing transaction_id from data layers)
    • conversion_time:-(Use the custom javascript variable to get the timestamp of the conversion in the UNIX format)
  • Trigger:- We will fire this event when our GA4 event “purchase” is pushed into the data layers. This is done because on this push we have all the values that we need for tiktok.

Implementing Magento TikTok Events API in GTM Server

Creating Necessary Variables

  • Variable Name:- Tiktok Event ID
  • Variable Type:- Event Data
  • Key Path:- event_id

Variable Name:- Tiktok Event Time
Variable Type:- Event Data
Key Path:- conversion_time

Variable Name:- Tiktok Email Hash
Variable Type:- Event Data
Key Path:- conversion_hashed_email

Variable Name:- Tiktok Phone Hash
Variable Type:- Event Data
Key Path:- conversion_hashed_phone

Variable Name:- Tiktok Click ID
Variable Type:- Event Data
Key Path:- ttiktok_click_id

Variable Name:- Tiktok Currency
Variable Type:- Event Data
Key Path:- currency

Variable Name:- Tiktok Value
Variable Type:- Event Data
Key Path:- revenue

Variable Name:- Tiktok Order ID
Variable Type:- Event Data
Key Path:- transaction_id

Create trigger

Please create a trigger based on the following settings:-

  • Trigger Name:- Tiktok Client
  • Trigger Type:- Custom
  • This trigger fires on:-
    • “Client Name” Equals “GA4”
    • “Event Name” Equals “tiktok_conversion”
    • “Event Name” does not Equals “purchase”
    • “Event Name” does not Equals “conversion_pii”

Note:- We have excluded certain events from our container space to avoid firing the tag multiple times. you are required to exclude GA4 purchase event if you dont have any other conversion events.

Create the Events API Tag

  • Tag Name:- Tiktok Conversion API
  • Tag Type:- Tiktok Events API by stape.io ( please import this tag from the gallery as its not available by default)
  • Event Name Setup Method:-
    • Standard:- Event Name:- Complete Payment
  • Event Source:- Web
  • Access Token:- Add the Events API access token that we obtained earlier
  • TikTok Pixel ID:- Add the tiktok Pixel ID
  • Test Event Code:- Please add this field when you are testing the server side events.
  •  Common Event Data Override:-
    • Event ID:- {{Tiktok Event ID}}
    • Event Time:- {{Tiktok Event Time}}
  • User Data:-
    • Email:- {{Tiktok Email Hash}}
    • Phone:- {{Tiktok Phone Hash}}
    • ttclid:- {{Tiktok Click ID}}
  • Properties:-
    • Currency:- {{Tiktok Currency}}
    • Value:- {{Tiktok Value}}
    • Order ID:- {{Tiktok Order ID}}
    • Content Type:- product
  • Consent Settings:- Send Data Always
  • Logs Settings:- Always Log to console
Tiktok GTM Server Side Tag

Testing and Debugging

Use GTM’s built-in testing tools to ensure that data is sent correctly to TikTok. Verify event tracking by checking the data flow and adjusting configurations as needed.

Tiktok Client Side GTM Tag:-

Tikok GTM Client Side Tag Firing

Tiktok Events API Tag:-

Tiktok Events API Server Side GTM Tag Firing

Leveraging TikTok Events Data

Building Custom Audiences

Use tracked data to create custom audiences in TikTok Ads Manager. This allows for targeted campaigns that reach users based on their interactions with your site.

Optimising Ad Campaigns

Leverage conversion data to refine bidding strategies and improve campaign performance. Use insights from tracked events to adjust ad targeting and messaging.

Analysing Campaign Performance

Analyse your TikTok Ads campaign data within TikTok Ads Manager. Use these insights to make informed decisions and enhance your marketing efforts.

Conclusion

Integrating the TikTok Events API with Magento using GTM Server-Side offers numerous benefits, including improved tracking accuracy and optimised advertising strategies. By implementing this integration, Magento store owners can unlock the full potential of TikTok advertising. For a seamless setup, consider using the Scommerce Mage extension, which simplifies the integration process and enhances your marketing capabilities.

Magento 1 / Open Mage:- https://www.scommerce-mage.com/magento-ga4-google-tag-manager.html

Magento 2:- https://www.scommerce-mage.com/magento-2-ga4-google-tag-manager.html

Similar Posts