Conversion Tracking

See the return on investment by tracking website visitors from your Facebook Ad and any associated actions they make on your site.

With Facebook pixel on all of key pages of your website, such 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.

This guide covers:

How it Works

To track conversions on your website from ads you're running on Facebook, create a Facebook pixel to place on your website.

Get the Pixel

To see how many checkouts your Facebook ads drives, put the pixel on the checkout confirmation page people see after completing a checkout. Whenever someone loads that page, the pixel tells Facebook the conversion event occurred.

Facebook matches that conversion event with people who viewed or clicked on your Facebook ads. You can provide a Conversion value with your pixel and Facebook calculates a return on investment for your ad spend. Later you can optimize your ads with oCPM and automatically show ads to people most likely to make conversions.

Currently you can only add 40 custom conversions due to constraints in reporting UIs. Each custom conversion needs three additional columns in reporting, so we limit events to maintain usability.

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.

Use Existing Pixels

a. Go to the Pixels Tab in Facebook Ads Manager.

b. Select Actions | Email Pixel Code:

c. Add an email then click Send.


Step 2: Copy the Pixel

Select and copy your Facebook pixel. The entire code must be placed in your website without modification in to track conversions. The code begins with a <script> and ends with a </noscript>. Do not to forget to copy a part or change anything. Your code looks like this:

Sample code only. To use it, change <FB_PIXEL_ID> to the Pixel ID for your Facebook pixel or it won't work. Also the base code loads on every page and the “Purchase” event should only load on your purchase confirmation page.

<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','//connect.facebook.net/en_US/fbevents.js');

fbq('init', '<FB_PIXEL_ID>');
fbq('track', 'PageView');

fbq('track', 'Purchase', { 
    content_type: 'product',
    content_ids: ['1234', '2345'],
    value: 67.50,
    currency: 'USD'
});
</script>

<noscript>
<img height="1" width="1" border="0" alt="" style="display:none" 
src="https://www.facebook.com/tr?id=<FB_PIXEL_ID>&amp;ev=PageView" />
<img height="1" width="1" border="0" alt="" style="display:none" 
src="https://www.facebook.com/tr?id=<FB_PIXEL_ID>&amp;ev=Purchase&amp;cd[content_type]=product&amp;
cd[content_ids]=1234,2345&amp;cd[value]=67.50&amp;cd[currency]=USD" />
</noscript>

Step 3: Paste pixel where you want to report conversions

Place the pixel immediately before the closing </head> tag in your HTML. If your site has a global include file, such as header.php, place the code there. Placing the code in the header isn't necessary, but improves the quality of events sent to Facebook.

You should only use one pixel for each page on your website where you want to track conversions. For example, don't include a registration type pixel and a Key Page View type pixel on the same confirmation page or you will double count this page in your reporting.



Step 4: Add Advanced Matching (Recommended)

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


Step 5: 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'});

You should also 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.

Step 6: Verify 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 check-out, account sign-in or registration process as parameters in the pixel. Facebook will then use 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, you will need to replace email, phone_number, first_name with the names of the variables on your website that capture this data.

For advertisers who do not 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.

Add your Pixel to Facebook Ads

After you add your pixel to your website, associate it with an ad. You must associate your pixel to an ad if you want to track conversions on that ad. You should set up your pixel in the same account that you plan to run your advertising campaign.

In Ads Create Flow

  • Go to Ads Create tool and choose Website Conversions as your objective.

  • Select the pixel you installed and verified. If you don't have a pixel, click the plus button to create one.

  • Click Continue and finish creating your ad

In Power Editor

  • Go to Power Editor and click 'Create Ad'. Click 'Create Ad' and select Website Conversions as your advertising objective.

  • Under Conversion Tracking section click Select Pixels to select an existing pixel or Create New Pixel to create a new pixel. You can report on multiple pixels or a single pixel depending on your reporting needs.

  • If your pixel is unverified, click Verify to verify that it's correctly tracking on your website.

  • Now you can enable URL Tracking for the pixel. This means the pixel reports on events based on a specific URL reached by your website's visitor:

  • Continue creating your ad. Once you're finished, click Upload Changes to save your changes to our ads system.

Reporting on Conversions

After you install the pixel and run a campaign that has ads with associated pixels, you can get reports on how your ad's performance towards your conversion objectives.

Report on ad conversions

  • Go to Ads Manager and click Campaign that has pixels associated with it.

  • In 'Columns: Performance', select Customize Columns....

  • Select Actions and Revenue to see in your report. For example, to see Website purchases your ads drove, select 'Website Actions' and then 'Purchases'. If you report a conversion value with your pixel you can also see return on ad spend by selecting 'Revenue' and then choosing 'Website Conversions'. To report on a specific conversion type select that conversion type in 'Actions'.
  • Click 'Apply'. The report lists of all your conversions sorted by your Campaign name.

Optimize for Conversions with oCPM

One of the most powerful features of Facebook Ads is the ability to automatically optimize for success with Optimized CPM or 'oCPM' bidding. When you enable this, Facebook uses an algorithm to find the people most likely to convert on your website and serve them ads automatically at the most efficient bid possible.

If your ads are not using Optimized CPM bidding, considering switching to oCPM to get better results.

Enable oCPM in Ads Manager

  • Go to Ads Create tool and choose Website Conversions as your objective.

  • Select the pixel you installed and verified. If you don't have a pixel, click the plus button to create one.

  • Under Bidding and Pricing select the following:

  • Finish creating your ad

Enable oCPM in Power Editor

  • Go to Power Editor and click 'Create Ad'. Click 'Create Ad' and select Website Conversions as your objective.

  • Under 'Optimization & Pricing' select 'Optimized CPM'. Use the recommended default or manually set your bidding thresholds.

  • Select the Facebook pixel used for optimization.

Your ads are optimized to display to the right people at the most efficient bid possible.

What's Next

Get Help with Conversion Tracking.

Ads Create Flow, a simple flow to run ads and access to all of our ads products. Learn how to create ads with Ads Create tutorial.

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

Facebook Marketing Developers are 3rd party developers specializing in management and optimization of campaigns and social marketing. If you are a partner, you can access Marketing API and build ads tools.