by ShahzadaAliHassan - 15th December 2023
In this Blog , we'll explore how to effectively integrate TikTok Pixel ViewCategory Event with your Shopify store using Google Tag Manager (GTM). This integration is crucial for leveraging TikTok's dynamic ad capabilities based on user interactions on your site.
To begin, it's crucial to confirm that your Shopify store includes the Google Tag Manager (GTM) Container, as this is key for tracking user interactions.
Start by embedding the Google Tag Manager scripts in your Shopify store. These scripts are vital for monitoring user activity and gathering significant data.
Proceed by embedding the head and body scripts from your Google Tag Manager container into the theme files of your Shopify store.
<head>
tag.<body>
tag.Post-script insertion, it's vital to check the setup to confirm that Google Tag Manager operates effectively on your Shopify store.
To confirm correct setup, utilize the Google Tag Manager’s preview feature. This helps verify that the container is operational on your Shopify store. Such a setup guarantees that Google Tag Manager is correctly configured in your Shopify store, essential for subsequent Analytics and Ads tracking and optimization.
Note Be sure to substitute 'GTM-XXXX' with your specific Google Tag Manager container ID.
In this comprehensive guide, we delve into the detailed process of integrating the TikTok base configuration tag into Google Tag Manager (GTM). This advanced setup involves acquiring the TikTok Pixel ID and the corresponding script from the TikTok Ads Manager, and subsequently embedding them into GTM as a custom HTML tag. Additionally, for streamlined future modifications, we will establish a variable specifically for the TikTok Pixel ID.
By meticulously following these enhanced steps, you will successfully implement a fully operational TikTok pixel in your Shopify store. This setup not only provides deep insights into customer interactions but also enhances the effectiveness of your digital marketing strategies.
The script initiates by setting up the dataLayer
array. Its first task is to determine if it's on a product page, and if so, it activates the 'datalayer-collection' snippet.
This script's main role is to add detailed product information to the dataLayer
when a collection page is visited:
itemObject
holding a variety of product details.dataLayer
.datalayer-collection.liquid
.This script runs the head-datalayer
snippet, typically embedded in the head section of a Shopify theme. It's essential for embedding the head datalayer code and should be integrated with the GTM Body Code.
Initial Backup: Start by creating a backup of your existing theme as a safety measure.
Accessing Theme Files: Go to your Shopify Admin, select Online Store > Themes, choose your active theme, click "Actions," and then "Edit code".
Inserting the Head DataLayer Script: In the theme.liquid
file found in the sidebar, insert the "Head DataLayer Script" within the <head>
tags.
Adding the Product DataLayer Script: Choose to "Add a new snippet" (this may vary based on the Shopify version). Name this new snippet datalayer-product.liquid
and incorporate the "Product DataLayer Script". Remember to save your changes.
Placing the Theme DataLayer Script: Identify a suitable location (usually within the <head>
of theme.liquid
) for the "Theme DataLayer Script". Insert and save.
Testing the Integration: Confirm the setup by visiting a product page on your Shopify store. Open the developer console in your browser to check if the custom_view_item
event is triggered and whether the dataLayer
shows correct product details.
In this essential section, we delve into setting up a custom purchase tag in Google Tag Manager (GTM) for TikTok's pixel. This process is vital for accurately tracking purchase events in your Shopify store. Follow these straightforward steps:
Log into GTM: Access your GTM account and navigate to the container associated with your Shopify store.
Select TikTok Pixel Template: In GTM, find and use the TikTok Pixel template. This template is specially designed for seamless TikTok pixel integration.
Tag Configuration: Input your TikTok Pixel ID in the 'Pixel ID' setting. Then, choose 'Complete Purchase' as the event type.
Data Layer Variables Setup: Extract essential user data (like email and phone number) through Data Layer Variables for precise tracking.
Define Event Parameters: Utilize the G4 data layer structure to specify event parameters such as 'currency', aligning with your e-commerce configuration.
Create Trigger for the Tag: Develop a custom event trigger that activates for your Shopify store's purchase event, matching the event name in your data layer script.
Save and Name Your Tag: After configuration, save your tag. A clear name, such as 'TikTok Purchase Event', is recommended for easy identification.
Testing and verifying your tag ensures it functions as intended:
Enable GTM Preview Mode: Activate preview mode in GTM for a live test connection with your Shopify store.
Simulate a Purchase: In your Shopify store, simulate a purchase transaction. You can use test mode or a 100% discount code for this purpose.
Verify the Purchase Event: Post-purchase, in the GTM debug window, check that the custom purchase event triggers correctly.
Use TikTok Pixel Helper: Confirm the correct firing of the 'Complete Purchase' event on the thank you page with the TikTok Pixel Helper tool.
Data Layer Verification: Ensure accurate transmission of transaction details (transaction ID, value, product details) and user data (email, phone number).
Publish GTM Container Changes: Once satisfied with the tracking accuracy, publish the changes in your GTM container to activate live tracking on your Shopify store.
Successfully configuring and verifying a custom purchase tag for TikTok in Google Tag Manager involves a systematic approach. From accessing GTM, choosing the right template, setting up tag configurations, to thorough testing and verification, each step is crucial for accurate event tracking. This setup not only provides valuable insights into customer behavior but also boosts the efficiency of your TikTok advertising campaigns. With this integration, you're well-equipped to harness TikTok's advertising power, leveraging data-driven strategies for your online store.