WooCommerce Facebook Pixel: View Category Ecommerce using DataLayer & Google Tag Manager

by ShahzadaAliHassan - 23rd May 2024

Hey there, WooCommerce store owners! This blog post is for you if you want to target specific audiences with Facebook Ads or segment your website visitors based on the categories they browse. In this guide, we'll walk you through configuring the View Category event for Facebook Pixel using Google Tag Manager (GTM).

What You'll Learn

Before We Begin

This blog post assumes you have a basic understanding of Google Tag Manager. We'll also be skipping explanations on general e-commerce training, Facebook marketing strategies, and complex coding.

Getting the Most Out of This Guide

For the best learning experience, follow these recommendations:

  1. Watch the video first: This will give you a foundational understanding of the process.
  2. Take notes: Jot down any questions you have while watching the video. You can address them in the comments section below or reach out to the author through the website (contact information should be provided).

Setting Up Google Tag Manager

There are several ways to configure GTM on your WooCommerce store. Here, we'll use a common plugin called GTM4WP.

  1. Install the GTM4WP Plugin:

    • Go to your WordPress dashboard and navigate to the Plugins section.
    • Search for "GTM4WP" and install the plugin by Thomas Drner.
    • Activate the plugin.
  2. Obtain Your GTM Container ID:

    • Go to the Google Tag Manager website (tagmanager.google.com).
    • Create a new container (or use an existing one) if needed.
    • Copy the container ID.
  3. Link GTM4WP to Your Container:

    • In your WordPress dashboard, go to Settings > Google Tag Manager.
    • Paste your GTM container ID into the designated field.
    • Enable the container code.
  4. Verify GTM Connection (Optional):

    • In GTM, click "Preview" to connect a temporary debug window to your website.
    • Visit a shop page on your website to test the connection.

Setting Up Facebook Pixel Configuration Tag

  1. Obtain Your Facebook Pixel ID:

    • Go to your Facebook Business Manager (business.facebook.com).
    • Click on "Events Manager" under the Tools menu.
    • Copy the Pixel ID from the "Data Sources" section.
  2. Create a Facebook Pixel Tag in GTM:

    • In GTM, go to Templates and search for "Facebook Pixel Tag."
    • Add the template to your workspace.
    • Create a new tag and select "All Pages" as the trigger.
    • Choose "Facebook Pixel" under Tag Type.
    • Paste your Facebook Pixel ID into the custom field.
    • Name the tag "Facebook Configuration Tag" for easy reference.
  3. Verify Facebook Pixel Connection (Optional):

    • Use the GTM preview and a Facebook Pixel Helper browser extension to confirm the Facebook Pixel is firing on your website.

Introduction to Data Layer

The data layer acts as a helper function, enabling you to track event parameters like product name, ID, price, and more. WooCommerce provides a built-in data layer that captures e-commerce events.

  1. Enable Data Layer Tracking in GTM4WP:

    • Go to the GTM4WP settings and navigate to the "Integration" section.
    • Enable "Track E-commerce Events" for the WooCommerce plugin.
    • Select "20" for the impression event.
    • Save the changes.
  2. Verify View Item List Event:

    • Visit a category page on your website.
    • Use the GTM debug window to see if the "View Item List" event is firing.

Creating a Tag for the View Category Event:

Building Dynamic Variables from Data Layer:

Renaming the Tag and Saving Changes:

Previewing and Verifying the Tag Functionality

Using Test Events for Final Verification

Publishing Changes and Bonus Section

Bonus Section Downloading Container for Easy Setup

A downloadable GTM container file containing the pre-configured tags and variables is available in the video description. This eliminates the need to recreate everything manually. Here's how to use it:

  1. Download the JSON file from the video description.
  2. In GTM, go to the container workspace.
  3. Click "Import Container" and select the downloaded JSON file.
  4. Choose "Use Existing Workspace" to avoid creating a new one.
  5. Select "Merge" to integrate the downloaded configuration without overriding your existing settings.
  6. Click "Confirm" to import the container.

Important Note: You'll still need to update the Facebook Pixel ID within the imported container for it to function correctly.

Conclusion

Congratulations! You've successfully configured the View Category event for Facebook Pixel on your WooCommerce store using Google Tag Manager. This allows you to track which product categories visitors browse and leverage this data for targeted Facebook Ads and website visitor segmentation strategies.

Stay tuned for the next video!

This blog post provides a comprehensive guide on setting up the View Category event. Remember to refer to the video tutorial for a more visual explanation, and don't hesitate to leave comments or reach out to the author if you have any questions.