How to Track Events in Facebook using Google Tag Manager

In the last chapter, we went through the process of installing the base Facebook pixel, which tracks user visits to various pages on the site. Facebook pixel provides another level of tracking that allows you to track specific actions that users take on your site. These actions are called Events in Facebook tracking.

Once you track these user actions, you can then create a custom audience on Facebook to target users with specific ads based on the actions they have taken on your site.

For example, if a user views a particular piece of content, you can then retarget that user on Facebook with similar content or if a user has purchased a particular product, you can retarget the user with ads about either a complimentary product or a similar product.

Figure: Sample of Facebook Events

Configuring the Tag

Note: Before following the steps in this chapter, make sure you have installed the Base Pixel as shown in the previous chapter.

If you haven't installed base, please go back to the previous chapter and follow the steps to install the base pixel.

Go to Facebook Ad Manager and click to get the Pixel Code. Since Facebook changes the interface quite frequently, you will have to use the Facebook help section if you don’t know where to get this code.

In the Facebook Pixel section, click on Set Up à Setup Event.

Figure: Facebook Event Data Selector screen 1

In the next screen, select Manually Add Event Code. You can also add Facebook’s Event Setup Tool if your event does not require sending any special data.

This will open another screen where you select your business category and associated events.

Figure: Facebook Business Category Selector

Pick the business category of your site and then pick one of the predefined events (or you can event set a custom one). These events are defined by Facebook to make it easier for you to configure them.

I selected View Content from the eCommerce business category to use as an example.

Using the “Add Another parameter” button, I added the “Content-Type” parameter. I will use it to pass the name of the location of the job listing the user is looking at. Once this is sent to Facebook, I can target users with location-appropriate ads on Facebook.

Since the location will change the listing on the page, I can’t hard code it on Facebook, so I am going to set it as a variable. Remember, we create a variable called “Listing Location”, we will use the same variable and it will populate this tag with actual values of location when it is executive in Google Tag Manager.

(Note: Code configuration in Facebook is not saved in the Facebook, so make sure to copy the code and paste it somewhere or leave the Facebook window open, else you will have to restart the pixel configuration)

Figure: Facebook Content View Pixel

Copy the code from Facebook and go to Google Tag Manager.

Configuring the Tag

Create a new Custom HTML tag.

Paste the Pixel code from Facebook into this Custom HTML tag.

Give the tag a name and then scroll down to click on Advanced Settings.

Under advanced settings, click on Tag Sequencing and check the box next to Fire a tag before [your tag name] fires.

Then you pick the tag that you want to fire before this tag.  For this tag to work properly, we need to fire Base Facebook Pixel Tag. Your final configuration will be as shown below

Figure: Facebook Content View Tag

Now, Click on Save to Save this tag. Next, click on Add Trigger.

Configuring the Trigger

In this case, we are not going to fire the Facebook Event tag on every page; we will only fire it on the page that contains Job Listings.

Create a new trigger and give it a name. The trigger is Clicked on page view. After that, select some page views that have an article containing job detail. Final configuration of this trigger is as follows

Figure: Facebook Event Trigger

Once done, save the trigger.

Preview the tag, and if everything looks good, go ahead and publish it.

Figure: Facebook Event Tracking in Preview.

After about 20 minutes,  log in to your Facebook Ads Manager, you will start to see the events data.

Figure: Facebook Event Report

Want to Learn Google Tag Manager. Here are few options:

  1. Get Google Tag Manager Book at Amazon
  2. Signup for Google Tag Manager Course on Udemy
  3. Signup for Optizent Academy and get Google Tag Manager + 20 other courses
  4. Free Introduction to Google Tag Manager course

Leave a Reply

Your email address will not be published. Required fields are marked *