by ShahzadaAliHassan - 13th December 2023
In this Blog , we'll explore how to effectively integrate TikTok Pixel ViewCart 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.
Begin by confirming the integration of the GTM Container with your Shopify store to monitor user activities.
Start by embedding the Google Tag Manager scripts in your Shopify store. These are essential for monitoring user actions and gathering data.
Proceed by incorporating the Google Tag Manager container's head and body scripts into your Shopify store's theme files.
<head>
opening tag.<body>
opening tag.Post-script insertion, verify the configuration to confirm Google Tag Manager's proper functionality on your Shopify store.
Use Google Tag Manager’s preview mode to confirm correct setup. This checks the container's activation on your Shopify store, establishing a foundation for subsequent Analytics and Ads tracking and enhancements.
Note Ensure to replace 'GTM-XXXX' with your specific Google Tag Manager container ID.
We're now shifting our focus to the integration of the TikTok base configuration tag within Google Tag Manager (GTM). This essential process involves the acquisition of your unique TikTok Pixel ID and its associated base script, which can be found in your TikTok Ads Manager. Once you've secured these, they need to be integrated into GTM via a custom HTML tag. Additionally, to streamline future modifications, we'll set up a variable specifically for the TikTok Pixel ID.
By meticulously following these enhanced steps, you'll establish a robust and fully operational TikTok pixel on your Shopify store. This setup not only offers invaluable insights into customer interactions and behaviors but also lays the groundwork for refined marketing strategies and customer engagement enhancement.
Here is the content converted into simple Markdown format without JSX:
This section focuses on capturing detailed data like item_id, item_name, value, quantity, etc., when the "custom_view_cart" event is triggered. The code snippets provided are designed to integrate the dataLayer
object with Google Tag Manager (GTM) in a Shopify store context. The primary objective is to send an event named custom_view_cart
whenever a user views the cart page in Shopify.
This code snippet ensures the initialization of the dataLayer
array and includes a specific snippet called 'datalayer-cart' for rendering on cart pages.
This snippet contains the logic to populate the dataLayer
object with product details whenever a View Cart event is triggered:
dataLayer
with the current cart information.This code renders the head-datalayer
snippet. Depending on the setup of your Shopify theme, this is likely where the head datalayer code resides. Add this code GTM Body Code.
theme.liquid
. Insert the "Head DataLayer Code" snippet within the <head>
tags.datalayer-cart.liquid
. Insert the "Cart DataLayer Code" snippet into this new file. Save changes.<head>
tags in theme.liquid
). Insert the "Theme DataLayer Code" snippet in the desired location. Save changes.custom_view_item
event is fired and the dataLayer
object contains the correct product details.The custom prefixes added to event names (like 'custom_view_cart') are intended to prevent conflicts with other possible integrations or plugins that might be using standard event names.
In this section, we'll outline the steps to set up a custom View Cart tag in Google Tag Manager (GTM) for your Shopify store. This is essential for tracking View Cart events and improving your e-commerce analytics.
Access Your Google Tag Manager Container: Log into your Google Tag Manager account and select the container associated with your Shopify store.
Create a New Tag: Go to the "Tags" section in the GTM dashboard. Click "New" to create a new tag dedicated to tracking View Cart events.
Tag Configuration: Choose a tag type that is optimal for tracking e-commerce cart viewing events. If a specific template for View Cart events exists, use it. Otherwise, consider creating a custom HTML tag.
Set Up the Trigger: Create a new trigger that fires when the View Cart action occurs. Name it clearly (like "CE custom_view_cart") to ensure clarity.
Configure the Tag: Enter necessary details such as your tracking ID or pixel ID. It's recommended to use variables for these details for easier future management.
Select the Event: Choose "View Cart" as the event this tag will track.
Object Properties: Configure object properties to capture details about the products in the cart, including their names, IDs, categories, and other relevant information. You can pull this data from your dataLayer or enter it manually.
Include the Currency Parameter: Make sure to include the currency parameter in the data sent with the View Cart event, particularly if your store operates with multiple currencies.
After setting up the custom View Cart tag, it's crucial to test and verify its functionality for accurate event tracking.
Enable Preview Mode: Switch on the preview mode in Google Tag Manager. This will allow you to see a debug view connected to your Shopify store for real-time monitoring of events, tags, and triggers.
Utilize Debugging Tools: Use browser extensions or other tools to monitor the tracking of View Cart events. Verify that all the necessary product data is being captured.
Simulate Cart Viewing: Browse through your Shopify store and add items to the cart, then view the cart. Check the debug window to ensure that the View Cart event is being triggered correctly.
Validate Event Data: Review the data sent with each View Cart event. Confirm that it accurately represents the products in the cart, including their names, IDs, categories, and currency.
Submit and Publish Changes: Once you are satisfied with the testing, submit your changes in Google Tag Manager and then publish them. This will enable the tracking of View Cart events on your Shopify store.
By following these steps, you can effectively set up and test a custom View Cart event in Google Tag Manager, thereby enhancing your e-commerce tracking and gaining valuable insights into customer behavior in the shopping cart stage.