by ShahzadaAliHassan - 11th December 2023
In this Blog , we'll explore how to effectively integrate TikTok Pixel Add to Cart 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.
First we need to make sure our GTM Container is present on the Shopify store to track all the user interaction.
First, add the Google Tag Manager scripts to your Shopify store. These scripts are critical for tracking user interactions and collecting valuable data.
Next, insert the head and body scripts from the Google Tag Manager container into your Shopify store’s theme files.
<head>
tag.<body>
tag.After inserting the scripts, it’s important to validate the setup to ensure that Google Tag Manager is functioning correctly on your Shopify store.
To ensure that everything is set up correctly, use the Google Tag Manager’s preview function. This will allow you to verify that the container is firing correctly on your Shopify store. This setup ensures that Google Tag Manager is properly configured in your Shopify store, laying the groundwork for other Analytics and Ads tracking and optimization.
Note Remember to replace 'GTM-XXXX' with your actual Google Tag Manager container ID.
Next, we focus on adding the TikTok base configuration tag in GTM. This process requires obtaining the TikTok Pixel ID and the base script from your TikTok Ads Manager. Once obtained, these are added to GTM as a custom HTML tag. For ease of future use, we also create a variable for the TikTok Pixel ID.
By following these steps, you'll have a fully functional TikTok pixel set up in your Shopify store, providing valuable insights into your customer's interactions and behaviors.
This section outlines how to enable a dataLayer
object for Google Tag Manager (GTM) in a Shopify store. The primary objective is to track when users click the AddToCart button on a product page, triggering a custom_add_to_cart
event.
The following code sets up the dataLayer
array if it's not already active. It specifically checks for 'product' page templates and applies a 'datalayer-product' snippet.
This snippet is the core for injecting product details into the dataLayer
when viewing a product page. It involves:
itemObject
with extensive product information.dataLayer
on document load.This script calls the head-datalayer
snippet. Depending on your Shopify theme setup, this is likely the location for the head datalayer script. Incorporate this into the GTM Body Code.
Procedures for Embedding DataLayer Scripts in Shopify:
Backup First: Always create a backup of your existing theme before modifications.
Theme File Access: Log into Shopify Admin. Navigate to Online Store > Themes. Select "Actions" for your live theme and choose "Edit code".
Embed Head DataLayer Script: Find theme.liquid
in the left sidebar and open it. Place the "Head DataLayer Code" within the <head>
section.
Insert Product DataLayer Script: Use "Add a new snippet" (varies by Shopify version). Name it datalayer-product.liquid
. Add the "Product DataLayer Code" to this file and save.
Place Theme DataLayer Script: Decide the script's location (typically in the <head>
of theme.liquid
). Insert the "Theme DataLayer Code" accordingly and save.
Verification: Check a product page on your Shopify store. Open the browser's developer console to ensure the custom_add_to_cart
event triggers and the dataLayer
has accurate product details.
Note: These steps are based on a standard Shopify configuration. Custom themes might necessitate alternative methods. Always conduct thorough testing before and after applying these changes.
In this section, we'll explore the steps to configure a custom Add to Cart tag in Google Tag Manager (GTM) to track cart additions in your Shopify store. This is crucial for capturing Add to Cart events and optimizing your marketing efforts.
Access Your Google Tag Manager Container: Sign in to Google Tag Manager and go to your Shopify store's container.
Create a New Tag: Go to the "Tags" section in GTM and click "New" to set up a tag for tracking Add to Cart events.
Tag Configuration: Choose a tag type suitable for tracking e-commerce events. If there's a specific template for Add to Cart events, use it. Otherwise, create a custom HTML tag.
Set Up the Trigger: Create a new trigger that fires on Add to Cart actions. Name it appropriately (like "CE custom_add_to_cart") to prevent any confusion.
Configure the Tag: Enter the necessary information, such as your tracking ID or pixel ID. Use variables for easy management.
Select the Event: Choose "Add to Cart" as the event this tag will track.
Object Properties: Define object properties to capture details about the added product, like name, ID, category, and other relevant information. Pull this data from your dataLayer or define it directly.
Include the Currency Parameter: If your store uses different currencies, make sure to include the currency parameter in the data sent with the Add to Cart event.
After setting up the custom Add to Cart tag, it's essential to test and verify its functionality to ensure accurate tracking.
Enable Preview Mode: Turn on preview mode in GTM to debug your Shopify store in real-time.
Use Debugging Tools: Utilize tools like browser extensions to monitor the tracking of Add to Cart events. Ensure that all necessary product data is included.
Test on Product Pages: Visit several product pages and add items to the cart. Check the debug window to confirm that the Add to Cart event is triggering correctly.
Validate Event Data: Review the data sent with each Add to Cart event to ensure it accurately reflects the added product, including name, ID, category, and currency.
Submit Changes: After verifying everything, submit your changes in Google Tag Manager.
Publish Changes: Click "Publish" in GTM to apply the changes to your Shopify store. This activates the Add to Cart tracking for your marketing analytics.
By adapting the steps used for configuring the TikTok View Content tag, you can effectively set up and test a custom Add to Cart event in Google Tag Manager, enhancing your e-commerce tracking and data analysis capabilities.