Measure Conversions

With Facebook pixel on all of key pages of your website (such as checkout pages, add-to-cart pages, or registration pages), see how many people take action on your ads and which Facebook Ad led to a conversion.

Conversion Tracking enables you to use optimized cost per impressions (oCPM) and show ads to people who are more likely to convert at the most efficient bid possible.

Install the Pixel

Facebook pixel is a small piece of JavaScript code that you copy and paste into key pages along your conversion funnel. Install this code and verify it works. You must have access to your web page's source code and be familiar with making changes to this source code. If not, send these instructions to your webmaster.

Add Advanced Matching (Recommended)

Send additional customer data through the pixel to match more website actions with Facebook users. See Advanced Matching.

Add Conversion Values (Optional)

You can optionally add a value to your conversion code by modifying Facebook pixel code. When you add a value to your pixel you can report your return on investment in Facebook reports. For example, if you spent $10 on Facebook Ads and the pixel reports $100 of value, your reported return on investment reported in Facebook Ads is $90.

You should ask your webmaster to add this value dynamically at the time a purchase it made.

To add a value to your conversion, you need to assign a new value to the 'value' field in custom data sent along with the tracking event. For example, if your checkout value was $9.99 you would modify the code like this:

fbq('track', 'Purchase', {'value':'9.99','currency':'USD'});

Modify the value variable within the IMG pixel at the bottom of the code like this:

<img height="1" width="1" alt="" style="display:none"
src="https://www.facebook.com/tr?id=<FB_PIXEL_ID>&amp;ev=Purchase&amp;cd[value]=9.99&amp;cd[currency]=USD"/>

If you would like to report a value in a currency other than US Dollars make sure you also modify the 'currency' field in custom data. For example, if you would like to report in Argentinian Pesos you would modify the code like this:

fbq('track', 'Purchase', {'value':'9.99','currency':'ARS'});

<img height="1" width="1" alt="" style="display:none"
src="https://www.facebook.com/tr?id=<FB_PIXEL_ID>&amp;ev=Purchase&amp;cd[value]=9.99&amp;cd[currency]=ARS"/> />

How you define a variable and pass it over from your website is based on how your site is implemented and what information you want to send. There are several standard options and you should consult with your web site's development team or webmaster to determine the best option:

  • Define a variable and send with the tracking event. This is similar to the approach above.
  • Create a macro and send the value in the tracking event, such as {{cart.total_price}}.
  • Use a tag manager to store values and send them with the tracking event.

Verify that the Pixel Works

The last step to installing the Facebook pixel is to verify it is working.

To verify the pixel is working, visit the page on which the pixel is installed. After a few hours open the Conversion Tracking tab in Facebook Ads Manager. Your pixel status should report 'Active' and the Activity chart should confirm your conversion traffic.

If the status remains Unverified and Activity is empty your pixel may not be installed properly. Review the steps above or ask your webmaster for help.

Advanced Matching with the Pixel

The Facebook pixel has an advanced matching feature that enables you to send your customer data through the pixel to match more website actions with Facebook users. With this additional data, you can report and optimize your ads for more conversions and build larger re-marketing audiences. You can pass the customer identifiers, such as email, phone number that you collect from your website during the checkout, account sign-in, or registration process as parameters in the pixel. Facebook then uses this information to match pixel events with Facebook users when the Facebook cookie is not present on the browser that fires the pixel.

To enable this feature, modify the default FB pixel code to pass data into the pixel init call.

fbq('init', '<FB_PIXEL_ID>', { 
  em: '{{_email_}}', 
  // Data will be hashed automatically via a dedicated function in FB pixel
    ph: '{{_phone_number_}}',
    fn: '{{_first_name_}}'
    ....
})

In the example above, replace email, phone_number, first_name with the names of the variables on your website that capture this data.

For advertisers who don't use the JavaScript, you can continue using the img tag to track and send data, but you must format and hash the customer data yourself.

<img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr/?id=12345678910&ev=Purchase&ud[em]=fb98d44ad7501a959f3f4f4a3f004fe2d9e581ea6207e218c4b02c08a4d75adf&ud[fn]=77646f5a4f3166637627abe998e7a1470fe72d8b430f067dafa86263f1f23f94&ud[ph]=b096a1f9e07810cca55a4b0114e721dda19ff2d6a2ab028b71adc06a34d46132&cd[value]=0.00&cd[currency]=USD" /> 

Video: Technical Integration

In this video, see the technical integration for Advanced Matching in the Facebook Pixel. This covers updating JavaScript pixel code, and using img tag with formatting and hashing raw data.

Data Type and Format

Use any of the following data types in clear text or sha256-hashed format:

  • email,
  • phone number,
  • first name,
  • last name,
  • city, state, zip
  • gender
  • date of birth.

For matching, you can send one identifier, such as email, or a combination of identifiers such as email + phone numbers, email + first name + last name + zip code. In general, you should always provide first name and last name with a date of birth or a zip code with city and state to achieve the best match rate.

If you pass clear text data through the pixel, Facebook hashes all the data using the sha256 algorithm at the browser. We do this with a dedicated function in the Facebook pixel library before we send it to our servers. We then use the hashed value to match pixel events to people on Facebook. The hashing function is only in the JavaScript pixel. If you use the image pixel, you should send Facebook data that has been previously hashed.

Before you send any data, in pre-hashed data or clear text format, check for correct formatting:

  • All data must be in lowercase
  • Remove all spaces
  • Each data type should be formatted following these guidelines:
Data Parameter Example Format Guideline

Email

em

jsmith@example.com

Lower case email address of person

First Name

fn

john

Lower case first name

Last Name

ln

smith

Lower case last name

Phone

ph

16505551212

Phone number, only digits with country code, area code, and number

Gender

ge

m

Either f or m, if unknown, leave blank

Date of Birth

db

19911226

Date of birth year, month, date, such as 19911226 for December 26, 1991

City

ct

menlopark

City in lower case with spaces removed

State

st

ca

2 letter state code

Zip

zp

94035

5 digit zip code

The guidelines for data formatting for Advanced Matching with Facebook Pixel are the same as the guidelines for Custom Audiences. To see the full guidelines see Facebook Help Center.

Data Security

Any customer data you pass through the Facebook JavaScript pixel is hashed locally on the browser before it goes to the Facebook servers for matching. If you use the image pixel, you are responsible for hashing the data prior to sending it to Facebook. This hashing process turns your data into short encrypted messages that are difficult to reverse engineer. We use these hashes to match people who have taken actions on your website with people on Facebook. Facebook typically deletes all matched and unmatched hashes within 48 hours after the matching process ends, unless we need to retain any data for troubleshooting or product improvement.

The Facebook pixel uses a secure https connection help protect any data transmitted from the browser to our servers.

Questions?

Get Help with Conversion Tracking.

Ads Manager, a simple flow to run ads and access to all of our ads products.

Power Editor is an advanced tool to run and manage a large number of campaigns with additional targeting options.

Facebook Marketing Partners are third-party developers who specialize in management and optimization of campaigns and social marketing.