For many companies, social traffic is very important. And there is one behemoth in the playground; Facebook. There are some great ways to use a Facebook Pixel in order to start measure conversions and optimize adverts you’re running on the platform. Not only that, the pixel allows you to create audiences for remarketing as well. That opens up for a really good targeting on Facebook for your audiences.

In order to start using the pixel you’ll have to create it using the Ads Manager.

Facebook Create Pixel

Just start by creating a pixel and giving a unique name. Note that you’re only allowed to have one Facebook Pixel per account, so choose a name that best represents your business.

Facebook Pixel Install Now

Once you’ve selected your name, hit the Install Pixel Now button, and you’ll see the actual code you need to add to your pages.

<!-- Facebook Pixel Code -->
fbq('init', 'XXXXXXXXXXXXXXXX');
fbq('track', 'PageView');
<noscript><img height="1" width="1" style="display:none"
<!-- DO NOT MODIFY -->
<!-- End Facebook Pixel Code -->

Note: You are going to need your id variable in the code (highlighted above) to be your own, so don’t copy/paste this code. Use the one you received in Facebook Ads Manager.

Head into your account in Google Tag Manager and create a new tag.

Google Tag Manager add Facebook Pixel

Tags -> Tag Configuration

Google Tag Manager Custom HTML for Facebook Pixel

Paste your code into the HTML Textarea above and make sure that you select All Pages under Triggering in order to have the tag fire on every page on your site.

Preview your changes in Google Tag Manager and make sure that the script fires as intended.

Google Tag Manager Preview Facebook Pixel

With that in place you’re now good to go and can publish your changes in Google Tag Manager. This will not make sure that you start tracking your users through the Facebook Pixel as well which will open up more possibilities in Facebook when it comes to following up what your users are doing (or not doing) on your site.

Add Facebook Conversion Tracking

Chances are that you don’t want to track only pages shown, but you probably want to add some Facebook conversion tracking as well. Facebook comes with some easy ways to follow up on conversion on your site as well. These include but are not limited to the following.

View Content

fbq('track', 'ViewContent');

Using this code on your content related pages ensures that Facebook will get information when users are visiting pages on your site. The code need to be added on the pages after the pixel code.

If you have a blog or specific product pages you’d like to track in order to see if your users are engaging with them, just add the code above to a Custom HTML tag (inside <script> tags) and make sure that the tag fires after the Facebook Pixel tag.

Google Tag Manager Trigger on Product Pages

On this particular site all product related content resides under the section /tjanster/ (services in English) so I’ll configured the Trigger to fire when Page has loaded (making sure that the Facebook Pixel is there). You could use Tag Sequencing instead if you like.

Add To Cart

fbq('track', 'AddToCart');

If you’re running an e-commerce and would like to track when your visitors are adding a product to the cart you would use the code above. Make sure that this code fires in the same sequence as your Google Analytics enhanced e-commerce tracking for AddToCart fires. Just add this line of code to the same function as you’re already using.

Complete Registration

fbq('track', 'CompleteRegistration');

If your intent is to have your visitors signing up for a service or subscription you will have to make use of the CompleteRegistration event code as stated above. Same goes as with the Add To Cart code; make sure to fire this line of code when the user has been registered or the form has been submitted.

Other Facebook Event Codes

There are numerous other event codes to be used, please see the Facebook official documentation. Just make sure to add them on your page when the event has actually happened. Do not add them when the page loads (except e.g. View Content) since that will skew your data.