Conversion Tracking

分类目录: Facebook像素

Conversion Tracking

Conversion Tracking enables you to see the return on investment of your Facebook Ads by tracking website visitors from your Facebook Ad and any associated actions they make on your site.

By placing the Facebook pixel on all of the key pages of your website, such as checkouts page, adds to cart page, or registrations page you’ll be able to know how many people take action on your advertising message and which Facebook Ad led to the conversion.

Conversion Tracking also helps businesses leverage optimized cost per impressions (oCPM) to show ads to people who are more likely to convert at the most efficient bid possible.

In this guide you will learn how to:

  • Associate the Facebook pixel with an Ad
  • Report on Conversions driven by Facebook Ads
  • Optimized Conversions

How it Works

If you want to track the conversions that happen on your website as a result of ads that you're running on Facebook, first create a Facebook pixel to place on your website.

Get the Pixel

For example to understand how many checkouts your Facebook ads are driving, you would put the pixel on the checkout confirmation page that people see after completing a checkout. Whenever a person loads that page, the pixel tells Facebook that the conversion event has occurred.

Facebook then matches that conversion event against the set of people who have viewed or clicked on your ads on Facebook. If you choose to provide a Conversion value with your pixel Facebook can even calculate a return on investment for your ad spend. Later you can optimize your ads using oCPM to automatically show your ads to people most likely to make conversions.

Right now you are limited to adding 20 custom conversions due to UI constraints. Each custom conversion requires an additional three columns to add to reporting, therefore we limit the events to maintain usability of the reports.

Install the Pixel

The Facebook pixel is a small piece of javascript code that you copy and paste into key pages along your conversion funnel. Installing this code into your website and verifying that it works is the first step towards reporting conversions and optimizing your Facebook ads.

In order to follow these instructions you must have access to your web page's source code and be reasonably familiar with making changes to this source code. If you do not have access or are not comfortable making changes, send these instructions to your webmaster.

To Use an Existing Pixel

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: Select and Copy the Pixel

Select and copy your Facebook pixel.

The entire code must be placed in your website without modification in order to track conversions. The code begins with a <script> and ends with a </noscript> . When you copy the code be careful not to forget to copy a part or change anything.

Your code should look like this:

The code below is an example. To use it make sure to change the <FB_PIXEL_ID> to the Pixel ID for your specific Facebook pixel or it won't work. Also the base code should load 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 the pixel into your webpage where you want to report conversions

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

Keep in mind that 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 else you may end up double counting this page in your reporting.



Step 4: Add Advanced Matching (Recommended)

This enables you to send additional customer data through the pixel to match more website actions with Facebook users. See Advanced Matching.


Step 5: Add a Value to your Conversion (Optional)

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

We recommend you 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 Walkthrough

In the below video we'll walk through the technical integration to begin using Advanced Matching in the Facebook Pixel. The video will cover updating the JavaScript pixel code, and how to utilize the img tag including formatting and hashing raw data.

Data Type and Format

We accept 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, please 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 Privacy

Any customer data you pass through the Facebook pixel is hashed locally on the browser before it goes to the Facebook servers for matching. This hashing process turns your data into short encrypted messages that cannot be tampered with. We use these hashes to match actions people have taken on your website with people on Facebook. Then Facebook deletes all matched and unmatched hashes within 48 hours after the matching process ends. We do not collect or store any raw personally identifiable information on our servers.

The Facebook pixel uses a secure https connection to ensure that any data transmitted from the browser will make it to our servers safely.

Adding your Pixel to a Facebook Ad

Once you've added your pixel on your website the next step is to associate your pixel with an advertisement. You must associate your pixel to an ad in order to track conversions on that ad.

Make sure you are setting up your pixel in the same account that you plan to run your advertising campaign.

In Ads Create Flow

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

  • Select the pixel you have previously installed and verified. If you don't have a pixel you want to use, 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.

  • At this point 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 creating and editing your ads in Power Editor, click Upload Changes at the top to upload your changes to our ads system.

Reporting on Conversions

After you have installed the pixel and run a campaign that has ads with pixels associated, you will be able to pull reports on how your ads performed against your conversion objectives.

To report on your ad conversions

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

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

  • In the pop up window select the Actions and Revenue that you would like to see in your report. For example, to see the number of Website purchases your ads have driven select the 'Website Actions' and then 'Purchases'. If you have chosen to report a conversion value with your pixel you can also report on 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 resulting report will contain a list 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 oCPM bidding Facebook uses a powerful 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 today considering switching to oCPM to get better results.

Enable oCPM in Ads Manager

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

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

  • Under the Bidding and Pricing section 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 advertising objective.

  • Under the 'Optimization & Pricing' section and select 'Optimized CPM'. You can use the default, which we recommended or manually set your bidding thresholds.

  • Select the Facebook pixel that you would like to optimize for.

Your ads will now be optimized to serve ads to the right people at the most efficient bid possible.

What's Next

Get Help with Conversion Tracking in our Help Center.

Ads Create Flow
is a simple flow for new advertisers to run ads and provides access to all of our ads products. Learn how to create ads with the Ads Create tutorial.

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

Preferred Marketing Developers
are 3rd party developers that specialize in managing and optimizing your campaigns and social marketing efforts. If you are a PMD, you can access our Ads API to build ads tools.