How to Install the Facebook Pixel on Your Website With GTM

In this article, I will show you how to properly install the basic Facebook pixel on your website.

After this step-by-step guide, you’ll be able to retarget Facebook users that have visited a specific page on your website.

Prefer seeing this detailed guide in a video format?

Storing Your Facebook Pixel in Google Tag Manager

Instead of placing your Facebook pixel directly on your website, it’s best practice to use a tag management system like Google Tag Manager.

The reason for this is because you will want to add more functionality to your Facebook pixel and track things like conversions values or other things that the Facebook pixel cannot do.

Also, each advertising platform (Facebook, Google, LinkedIn, Twitter…) all have their own pixel and tracking codes. Imagine having to configure all these on your website. With Google Tag Manager you need to install it once on your website and simply add your tracking codes in the tool. NO CODING SKILLS REQUIRED!

1. Create & Install Google Tag Manager on Your Website

The first step is to create a free Google Tag Manager (GTM) account. This process is quite simple and once you’ve completed the registration you should see something like this:

Look inside Google Tag Manager

For this walkthrough, we are going to be using WordPress as our CMS system. If your website is one Shopify, Wix, PageCloud… the process is really similar.

1. Navigate to the “Plugins” section on the sidebar

2. Click the “Add New” button.

How to Install a plugin

3. In the search bar type “Google Tag Manager“.

4. Locate the “Google Tag Manager for WordPress” plugin by “Thomas Geiger“.

5. Click the “Install Now” button and then “Activate“.

Google Tag Manager Plugin Installed

6. Navigate to the plugin we just installed Settings > Google Tag Manager.

How to get to the Google Tag Manager Plugin

7. Go into Google Tag Manager to copy your ID and paste it into the ID input.

How to get your Google Tag Manager ID
Pasting a Google Tag Manager ID in the plugin

8. In the “Container code placement” section please select “Custom (needs tweak in your template) and click “Save Changes“.

Custom tweaks in GTM plugin & save

9. Copy the code here:

<?php if ( function_exists( ‘gtm4wp_the_gtm_tag’ ) ) { gtm4wp_the_gtm_tag(); } ?>

Navigate to “Appearance > Theme Editor” and locate & click “Theme Header“. 

Adding Google Tag Manager in the theme

10. Right under the first opening “<body” tag insert the code you just copied above and click “Update File“.

Addin the GTM code in the theme editor

Congrats! Google Tag Manager is now installed on your website.

2. Add Your Facebook Pixel in Google Tag manager

1. You’ll need to locate your Facebook pixel ID by going to Facebook Ads Manager > Events Manager.

How to find your facebook pixel ID

2. Click to copy the pixel ID and save it somewhere.

Copy your Facebook Pixel ID

3. Navigate back to Google Tag Manager and click on “Tags” and click “New

How to create a tag in Google Tag Manager

4. Name your tag “FB – Basic Tracking – All Pages“, click “Tag Configuration” and chose the option “Custom HTML“.

Naming your tag and choosing a tag type

5. Now enter the code below and where it says “ENTER-YOUR-ID” enter your FB pixel ID:

<!– Facebook Pixel Code –>
<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version=’2.0′;
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,’script’,
‘https://connect.facebook.net/en_US/fbevents.js’);
fbq(‘init’, ‘ENTER-YOUR-ID’);
</script>
<!– End Facebook Pixel Code –>

6. Click on “Advanced Settings” and add a “Tag firing priority” of “100“.

Adding a tag priority in google tag manager

7. Click on “Triggering“, chose the option “All Pages” and click the “Save” button in the top right corner.

How to create a trigger in Google tag manager

8. Now we need to add one more tag so again repeat the process, click on “New“, name this tag “FB – Pageview – All Pages“, click “Tag Configuration” and chose “Custom HTML“.

9. Paste this exact code in the HTML section:

<script>
fbq(‘track’, ‘PageView’);
</script>

10. Once again, click on “Triggering“, chose the option “All Pages” and click the “Save” button in the top right corner.

11. The last step is to simply publish your changes by clicking the “Submit” button at the top right and give it a name like “Installed FB pixel” and click “Publish“.

Sub,iting changes to Google Tag Manager

Need Assistance With The Installation?

Implementing the Facebook pixel on your website is a must whether you’re running Facebook ads or not!

If you need any help or have questions about implementing a Facebook pixel on your website we at Vertex can help you with that and help you track some more advanced things like conversions.

Pin It on Pinterest

Share This