Last updated 23 January 2017. Created on 31 March 2016.
Edited by josueValRob, silkogelman, Perignon. Log in to edit this page.

Step by step overview of configuring the different sections of Facebook Tracking Pixel module.

Define what roles should be tracked

go to Configuration -> System -> Administer Facebook Tracking Pixel (its at url admin/config/system/facebook_tracking_pixel)

The tab ‘Administer Facebook Tracking Pixel’ should now be active and you'll see an interface very similar to this:

Selecting the roles you want to track

Select the ‘Roles to track’
select the roles you want to track with the Facebook Tracking pixel. In most cases you’d want to select ‘Anonymous user’. If the goal is to track e-commerce sales with Drupal Commerce, and want to track both anonymous checkout and authenticated checkout make sure to also check the box next to the role that is given to (potential) customers when they login as wel as the ‘anonymous’ role.

Click ‘Save configuration’.

Add the base tracking code

First, let’s find your Facebook ad account pixel id.
go to your Facebook Ad Account, and select ‘Pixels’ under the ‘Tools’ dropdown.
On the right sidebar of that page you’ll see a block of content that has the text ‘Pixel: Ad account name’s Pixel’. Under that title, you’ll see ‘id: [the id]’
Copy that number.

facebook ads manager pixel id

Now go to the tab ‘Base tracking codes’ (url is admin/config/system/facebook_tracking_pixel/base_codes).
You'll see an interface very similar to this:

Adding the base pixel

Type a name in the name column. In most cases entering the same name as the ‘Facebook ad account’ name is a safe bet. Any other name is ok as long as you and other administrators are able to identify the ad account with it. Now paste the Facebook ad account pixel id we noted earlier into the ‘Facebook id number’ column.

Hit the ‘Add’ button.

checkbox global

Note that the checkbox ‘Global’ is enabled by default. This enables tracking all pages of the website. For most cases that is what you’d want.
In some cases only the pages where special events take place should be tracked. In that case disable this ‘Global’ checkbox, and the Facebook base code is only added to the pages where Facebook events are added to.

multiple base pixels

You can add multiple base pixels to a website, in use cases where multiple ad accounts do promotions for one website.
After adding the accounts you can sort their order by moving them up and down the list. The order in this list determines the order in which te base pixels are loaded on the site. Make sure to hit the ‘Save Arrangement’ button if your satisfied with the order.

Facebook Event Tracking via Drupal Path

The Facebook Tracking Pixel module allows you to fire Facebook events when a visitor visits a certain path.

contact page as lead

In this example we’ll send the ‘Lead’ event to Facebook if a person reaches our contact page located at ‘’ (in this example our contact page has node id 1).

note: you can only add events to paths that exist on the site.

Go to the tab ‘track events by path’ (url is admin/config/system/facebook_tracking_pixel/path)
click on ‘Add tracking based on path’ (admin/config/system/facebook_tracking_pixel/path/add)

Enter ‘Contact page lead’ under ‘Tracker Name’.
Select the ‘Lead’ checkbox
at ‘Path for Tracker’ you have to make a choice:
enter the path based on node id (’node/1’), or based on clean url (‘contact’). In terms of tracking it doesn’t matter which one you choose as Facebook Tracking Pixel automatically tracks the alias path too (in this case ’contact’ if you enter ‘node/1’). However it make a difference in the case where you add a tracker based on clean url (‘contact’) and the url of that node is changed to ‘contact-me’ at a later point in time. If that is prone to happen in your usecase change you’re probably better off tracking by node id path.

Tracking Drupal Commerce Sales


Track User Registration


How to know if my code is working?



Provided for troubleshooting and "when all else fails" scenarios, there is a purge function (admin/config/system/facebook_tracking_pixel/purge). By clicking Purge All every code on the site and every path tracking event will be erased. This will also reset all Commerce tracking settings as well. This removes everything from the database and deletes all files that have been created. It will return the module to a state of initial installation.

Looking for support? Visit the forums, or join #drupal-support in IRC.