If you’re already using Facebook as a marketing tool, you want to measure the results, right? You have multiple options here – remarketing, Facebook conversion tracking, etc. However everything takes time to implement – you send an email to the developer with requirements of what should be tracked and it takes him weeks complete the task. But not anymore! With the help of Google Tag Manager you can drastically speed up the process.

BEFORE YOU CONTINUE

This blog post assumes you have a working knowledge of Google Tag Manager tags. If you’re a beginner – I highly recommend checking out these free Google Tag Manager courses, first. The minimum requirements are:

You have Google Tag Manager tracking code installed on your website.

You know what tags, triggers, variables and dataLayer are and how they work in Google Tag Manager.

P.S. This blog post is a part of more comprehensive guide – Google Tag Manager + Facebook, so if you’re looking for in-depth information about how to upgrade your Facebook marketing with Google Tag Manager, give it a try.

GET THE ULTIMATE LIST OF 120+ GOOGLE TAG MANAGER RESOURCES. EVERYTHING FROM A TO Z.

Please wait...

You have successfully subscribed. Go check your inbox.

Please enter your email address

Please enter a valid email address

Unexpected error occurred!

SO WHAT’S THE PLAN?

If you’re familiar with Twitter conversion tracking setup process via Google Tag Manager, with Facebook it is pretty similar. All you need to do is:

In Google Tag Manager, create Custom HTML tag and paste Facebook Pixel’s code (I have described it in this blog post).

Create additional event tags which send interaction data to Facebook (that’s what I’ll explain in this blog post). That data will be used to create more precise remarketing audiences.

GET THE ULTIMATE LIST OF 120+ GOOGLE TAG MANAGER RESOURCES. EVERYTHING FROM A TO Z.

Please wait...

You have successfully subscribed. Go check your inbox.

Please enter your email address

Please enter a valid email address

Unexpected error occurred!

Facebook Conversion Tracking with GTM

To optimize and measure Facebook ad campaigns, you need to track important events on your website and send that data to Facebook.

Those “important events” (in Facebook documentation and interface) are called Standard events. Currently there are 9 supported types of events:

When important event occurs on your website, you have to fire a separate piece of code in addition to your Facebook Pixeltag, so that you can measure when someone submits a form, clicks a button or makes a purchase.

You can later use those events to build audiences with custom combinations, e.g. “Show ads to those people who Added product to their cart in last 30 days.

You can even go one step further by mixing several events in one remarketing audience, e.g. show my ads to those who added product to cart and visited certain pages but did not make a purchase.

The sky is the limit.

ADD STANDARD FACEBOOK PIXEL EVENTS WITH GOOGLE TAG MANAGER

For every interaction you want to track with Facebook, you’ll need to create a separate GTM Custom HTML tag with few lines of code. For example:

1

2

3

4

5

6

7

8

<script>

fbq('track','Lead',{

content_name:'name',//this is just an example. You should replace it with actual value

content_category:'category',//this is just an example. You should replace it with actual value

value:30,//this is just an example. You should replace it with actual value

currency:'USD'//this is just an example. You should replace it with actual value

});

</script>

Few things I’d like to mention:

Make sure that Facebook Pixel tag (mentioned in chapter No. 2 of this blog post) fires before any Facebook event tag. The best way to do that is to set higher priority to Pixel tag.

With Google Tag Manager, I can easily insert any variables which transfer information from your website (depending on context) to Facebook. As you can see in the code example above, with Lead type of event (when visitor subscribes to newsletter) I also transfer form’s position which is dynamically inserted via Data Layer variable {{dlv – formPosition}}.Very useful: check out this list of all available data attributes that can be passed along with Standard Facebook Events.

Content_name, content_category and other attributes are not required in event code, but they give you better understanding which lead generation forms perform better. If you don’t want to track such specific data, basic event code will do just fine:

1

2

3

<script>

fbq('track','Lead');

</script>

To give a better understanding of Facebook Standard events, I’ll give you brief explanation of each one of them.

FACEBOOK STANDARD EVENT – VIEW CONTENT

If you’re tracking visitors on a blog, ViewContent Facebook eventshould fire when visitor navigates to a blog post page. If you’re the owner of e-commerce business, then your content is a product page. Sample tag could look like this:

Trigger’s (that I used for this Custom HTML Facebook tag) settings are:

FACEBOOK STANDARD EVENT – SEARCH

search_string:'search term',//this is just an example. You should replace it with actual value

content_ids:'id1234',//this is just an example. You should replace it with actual value

content_type:'product'//this is just an example. You should replace it with actual value

});

</script>

When a visitor uses search on my blog, page’s URL changes to analyticsmania.com/?s=search_query. So for Facebook Search Tag I’ll use trigger with the following settings:

Title – Pageview – Used Search.

Type – Pageview.

This trigger fires on – Some Page Views

Rule – Page Path starts with /?s=

Keep in mind, additional parameters (i.e. search_string) are optional. This applies to all Facebook events.

FACEBOOK STANDARD EVENT – ADD TO CART

1

2

3

4

5

6

7

8

9

<script>

fbq('track','AddToCart',{

content_ids:'id1234',//this is just an example. You should replace it with actual value

content_type:'product',//this is just an example. You should replace it with actual value

content_name:'Product name',//for single item

value:30,

currency:'USD'

});

</script>

If you own an online store, then this event is pretty important in order to measure sales funnel. Every e-commerce platform is really different, so it’s impossible to describe a standard method how to track Added to cart event.

The most robust solution would be to ask developer to send this interaction as a dataLayer event. Then you could catch that event with Google Tag Manager and use it as a trigger which launches AddToCart Facebook Event.

FACEBOOK STANDARD EVENT – ADD TO WISHLIST

content_ids:'id1234',//this is just an example. You should replace it with actual value

content_category:'category',//this is just an example. You should replace it with actual value

content_name:'Product name',//for single item

value:30,//this is just an example. You should replace it with actual value

currency:'USD'//this is just an example. You should replace it with actual value

});

</script>

The issue is pretty similar to Add To Cart events – it’s impossible to write a solution that fits all online stores. The most robust solution is to ask developer to send this interaction as a dataLayer event.

FACEBOOK STANDARD EVENT – INITIATE CHECKOUT

1

2

3

4

5

6

7

8

9

10

<script>

fbq('track','InitiateCheckout',{

content_ids:'id1234',//this is just an example. You should replace it with actual value

content_category:'category',//this is just an example. You should replace it with actual value

content_name:'name',//for single item

value:30,//this is just an example. You should replace it with actual value

currency:'USD',//this is just an example. You should replace it with actual value

num_items:4//this is just an example. You should replace it with actual value

});

</script>

If your checkout process consists of more than one step, then usually step 1 has some unique string in the URL, e.g. sampleshop.com/checkout/step1/some_other_stuff. In that case you can use Pageview Trigger with the following rules (remember – it’s only an example. In your case Page Path might be different):

Title – Pageview – Initiated Checkout.

Type – Pageview.

This trigger fires on – Some Page Views.

Rule – Page Pats contains /checkout/step1/

FACEBOOK STANDARD EVENT – ADDED PAYMENT INFO

1

2

3

4

5

6

7

8

<script>

fbq('track','AddPaymentInfo',{

content_ids:'id1234',//this is just an example. You should replace it with actual value

content_category:'category',//this is just an example. You should replace it with actual value

value:30,//this is just an example. You should replace it with actual value

currency:'USD'

});

</script>

There are two most common scenarios how we can identify that visitor entered payment information:

Either he/she visited a particular page with unique URL. Then, you should use Pageview trigger (like I have described InitiateCheckout tag).

Or the URL does not change when payment info is entered. In that case – ask developer to send dataLayer event, whenpayment information was successfully saved. Actually, I’d ask to add two events: 1. User started entering payment information. 2. User successfully entered information. This way I could see how many people bounced off my checkout process in this step.

The same principle (Pageview or Data Layer event) can be also applied to the following Facebook Standard events:

content_ids:'id1234',//this is just an example. You should replace it with actual value

content_name:'name',//for single item

content_type:'product',

value:30,//this is just an example. You should replace it with actual value

currency:'USD',//this is just an example. You should replace it with actual value

num_items:4//this is just an example. You should replace it with actual value

});

</script>

Very useful information: I highly recommend reading my guide of 5 form tracking methods with Google Tag Manager. It will be especially useful if you’re want to track Lead or CompleteRegistration Facebook events. Chances are you won’t need developer’s input at all when it comes to tracking form submissions.

When you set up all Facebook tags, do not forget to test them:

Utilize GTM’s Preview and Debug mode to see if tags fire when they suppose to.

FACEBOOK CUSTOM EVENTS

Also, Facebook lets you send any event name you want and any number of key/value combinations you want. Basically, they created an ability to push your entire dataLayer to their platform.

Do you want to create a Facebook audience based on user’s pricing plan or amount of the last payment? No problem. Just use trackCustom method. It works the same way as aforementioned methods, expect you can define your own title, parameters and values.

Say, I own a website a SaaS business and my website contains a pricing form. Visitors can enter their number of subscribers (because pricing of my SaaS depends on the size of subscribers list) and then the form calculates the price.

When the price is calculated, the form GTM fires a custom HTML tag with Facebook Custom Event called usedPricingForm with 2 parameters: pricingRange and numberOfContacts.

1

2

3

4

5

6

<script>

fbq('trackCustom','usedPricingForm',{

pricingRange:'100-150',

numberOfContacts:24500

});

</script>

If a visitor used my pricing form (calculator), he is probably interested in my SaaS’ services, right? I could then create a FB remarketing audience based on usedPricingForm event and even create different ads based on visitors’ pricing range.

If you wish, you can add 5 or even 10 additional parameters to your custom events. To be honest, I am not aware of the actual limit of custom parameters. Surely, there is one, but I was a bit lazy to test 🙂

FACEBOOK CONVERSION TRACKING: THINGS TO KEEP IN MIND

It may take up to 24 hours for data to appear in Facebook Business Manager dashboard (but usually it’s processed faster).

Minimum size of an audience is 20. So you can start remarketing much faster, compared to Google Adwords, where minimum list size is 100 for Google Display Network and 1000 for Google Search.

Before you start tagging, prepare a measurement plan – a list of what you really need to track. It will bring more transparency, help you plan ahead and avoid inconsistency problems.

Test, test, test before publishing – devil is in the detail. One tiny mistake can lead to huge problems.

I will not go into details how to setup the actual ad campaign in Facebook. So if you’re new to this, go check out Impact’s blog post.

Facebook CONVERSION TRACKING: CONCLUSION

Facebook conversion tracking is pretty similar to Adwords or Twitter conversion tracking in Google Tag Manager. First, you need to decide which website interactions are important to you. Then set those events within GTM as triggers (e.g. “Visited Thank You Page”) and link them to Custom HTML tags which contain codes of Facebook events.

Remember: for every important interaction you need to create a distinct Custom HTML Facebook event tag within Google Tag Manager.

Facebook conversion tracking enables you to measure your ad campaigns and see which ones drive more signups or sales.

Did I miss something in this blog post? If yes, let me know in the comments!

GET THE ULTIMATE LIST OF 120+ GOOGLE TAG MANAGER RESOURCES. EVERYTHING FROM A TO Z.

Hello! Thanks for the article. I am just wondering, what kind of difference is in this case between these 9 types of standard events? I mean, basically you could use AddToCart event for your leads (triggering the AddToCart events to fire upon pressing the button “Become a lead” on your website), etc., couldn’t you? Technically, for Facebook there is no difference in how you name the event, it just uses the same naming to appear in reports but what are you tracking with it is up to you, am I right?

Hello Tania, yes, you are right. You can assign any interaction to “Lead” event. It’s up to you, although doing this would make your data more hard to read/understand, especially for another person. So keep that in mind.