Secret to Setup Facebook Pixel Tracking Correctly in Google Tag Manager

Video Transcript

Do you know………….most likely…………..your Facebook Pixel tracking in Google Tag Manager……… is not set up correctly…..and it is costing you money…..

Hi!

I am Himanshu

And today i am going to show you…………how to setup Facebook Pixel Tracking Correctly when using Google Tag Manager.

You probably know that……..Google Tag Manager…..doesn’t play well with Facebook.

For example, the Facebook JavaScript SDK code can not be deployed via GTM.

This is the SDK code you need……if you want to use a Facebook plugin like….. Facebook Like button…. Or Facebook Follow button.

This is the code you need….if you want to track Facebook Social Interactions like: ‘Facebook Likes’.

While you may not be able to deploy the Facebook SDK code via GTM, you can still deploy the Facebook default pixel code via GTM.

I have got an article on setting up Facebook pixel tracking via GTM: Learn to setup Facebook Pixel Tracking via Google Tag Manager

So I won’t be sharing the A to Z details of……how to set up the Facebook pixel tracking…..

What I am going to share with you…..is that one little tweak….that one secret…..which can make world of difference….

I have noticed that…… when you fire facebook pixel via GTM, facebook record hits from the domain gtm-msr.appspot.com .

You can confirm that by checking your pixel data in Facebook.

From your Power Editor or Ads Manager,……whatever you use, click on the ‘Pixels’ link:

Then click on the ‘Details’ button:

Now click on the ‘Activity’ tab:

Here you can see the list of all the events recorded by Facebook.

Lets click on the ‘Purchase’ event:

Now look at the Referring URLs column on the right hand side:

Can you see gtm-msr.appspot.com/render2…. as the referring URLs?

Hits from this domain…. is inflating my purchase event pixel data.

Now this is really bad because Facebook machine learning algorithm uses the pixel data to optimize my Facebook campaigns for conversions.

And if the machine learning algorithm is going to get the corrupted pixel data ………….then how on earth……it will be able to find the audience………..who are most likely to make a purchase on my website.

So we need to stop the Facebook pixel from firing……..whenever the current URL contains appspot.com and whenever the referrer is appspot.com.

You can do that by modifying the Facebook pixel code in such a way………….. that it fires only when the following condition is true:

For example, following custom HTML tag is used to fire the default pixel code:

Here you can see the additional line of code….added at the top…..which checks………whether the current URL contains appspot.com and whether the referrer is appspot.com………If yes then do not fire the facebook pixel code.

Use this same additional code for tracking all Facebook events like ‘add to cart’, ‘purchases’ etc:

For example this one is for ‘add to cart’ tag:

Here also you can see the additional line of code….added at the top…..which checks………whether the current URL contains appspot.com and whether the referrer is appspot.com………If that is the case… then do not fire the ‘add to cart’ event code.

All right.

That’s all for now.

See you soon.

Take Care. Bye!

Related Articles

Most Popular E-Books from OptimizeSmart

Learn to read e-commerce reports book banner

How to learn and master Web Analytics and Google Analytics?

Take the Course

Check out my best selling books on Web Analytics and Conversion Optimization on Amazon

How to get lot more useful information?

I share lot more useful information on Web Analytics and Google Analytics on LinkedIn then I can via any other medium. So there is really an incentive for you, to follow me there.

Himanshu Sharma

Certified web analyst and founder of OptimizeSmart.com

My name is Himanshu Sharma and I help businesses find and fix their Google Analytics and conversion issues. If you have any questions or comments please contact me.

  • Over twelve years' experience in SEO, PPC and web analytics
  • Google Analytics certified
  • Google AdWords certified
  • Nominated for Digital Analytics Association Award for Excellence
  • Bachelors degree in Internet Science
  • Founder of OptimizeSmart.com and EventEducation.com

I am also the author of four books:

error: Alert: Content is protected !!