Tracking Pageview event on Shopify using Google Tag Manager and Facebook Pixel.
by ShahzadaAliHassan - 10th November 2023
Introduction
In our latest tutorial, we dive into the process of integrating Facebook Pixel with your Shopify store using Google Tag Manager. This approach is particularly useful if you're experiencing issues with Shopify's native Facebook and Instagram app tracking.
Understanding the Complexities
Before we begin, it's crucial to acknowledge that migrating from Shopify's native integration to Google Tag Manager entails a complex setup involving cookies and server-side tracking. This method is recommended for those who have prior experience or a deep understanding of these systems.
Prerequisites
The tutorial assumes that you already have a Google Tag Manager container account, a Facebook Business Manager account, and a Shopify store ready for configuration.
Step-by-Step Guide
Section One: Configuring Google Tag Manager on Shopify
- Access your Google Tag Manager container.
- Navigate to 'Admin' > 'Install Google Tag Manager' to obtain the necessary tracking snippet codes for Shopify's head and body sections.
Adding the Codes to Shopify
- Within your Shopify store, go to 'Sales Channel' > 'Online Store' to reach the themes section.
- Choose 'Edit Code' and locate the 'theme.liquid' file.
- Insert the head snippet code within the opening head tag and the body snippet code below the opening body tag.
- Ensure correct formatting and indentation for clarity, then save your changes.
Verifying the Integration
- Return to the workspace in Google Tag Manager and select 'Preview'.
- This connects your store with the Shopify debug view to monitor events firing on your website.
Section Two: Configuring the Basic Facebook Pixel Tag
- Head over to Facebook Business Manager and locate 'Events Manager' under 'All Tools'.
- In 'Data Sources', select your Facebook pixel or create a new one if necessary.
- Use either custom HTML tags or template tags to configure your pixel. We will focus on custom HTML tags first.
Creating a Custom HTML Tag in Google Tag Manager
- In Google Tag Manager, go to 'Tags' > 'New' and choose 'Custom HTML Tag'.
- Copy the base code provided by Facebook for manual setup and paste it into the tag configuration.
- Set the trigger to 'All Pages' to ensure the tag fires across your website.
Testing the Facebook Pixel Integration
- Use the 'Preview' mode in Google Tag Manager to confirm that the Facebook pixel is firing correctly.
- Disable any native Shopify Facebook integrations to avoid conflicts.
Section Three: Using Templates for Easier Configuration
- Explore template tags provided by the community within Google Tag Manager.
- Add a Facebook pixel template from the tag gallery and configure it with your Facebook pixel ID.
- Rename the tag appropriately and save your settings.
Publishing and Testing
- Publish the Google Tag Manager container after final testing.
- Use Facebook Business Manager's 'Test Events' feature to validate event tracking on your Shopify store.
Observing Results
- Enter your website's URL in the 'Test Events' section to link it with Facebook's debug view.
- Monitor page views and other events to ensure they register correctly.
Conclusion
This detailed guide is designed to give you a granular look at setting up Facebook Pixel on Shopify using Google Tag Manager. By following these steps, you'll be able to track valuable customer interactions on your Shopify store with precision.