Facebook Pixel

分类目录: Facebook像素

Getting Started with the Facebook Pixel

Engage your websites audience based on pages they visit or actions they take.


Track actions such as registering, purchasing items, and so on. These actions can be used to retarget audiences, find new customers, track conversions coming from your Facebook ads, and ultimately allow Facebook to automatically optimize your ads to result in more of these actions. We recommend adding the pixel to your site for the following use cases:

  • Track and Optimize Conversions – Enable Facebook to both report back on the number of actions Facebook ads drive as well as allow Facebook to learn which people that see your ads are more likely to result in doing a certain action on your site, such as a purchase, and optimize the delivery of ads to result in more of these actions.

  • Website Custom Audiences – Record page visits and actions from all visitors on your site, not just visitors that click on Facebook ads. Use this data to create Website Custom Audiences for retargeting with your Facebook Ads.

The pixel comes with standard events that you can use on your site. Standard events are able to be used for Custom Audiences, custom conversions, conversion tracking, and conversion optimization. Additionally, the pixel allows you to use custom events that are usable for Custom Audiences or custom conversions.

In the past, you had to use two different pixels to target Custom Audiences, track conversions and optimize for conversions. If you wanted to track different conversions you also had to add a different pixel on each for page for each action you wanted to track. The Facebook pixel combines all of these functions into a single pixel you add to your entire website and then use standard events or custom conversions to define the actions which matter to you.

Existing Conversion Tracking pixels and Custom Audience pixels will continue to work as before, but we recommend you upgrade to the latest version of the Facebook pixel and migrate your conversion events to take advantage of the new features.

Get the Pixel

The Facebook pixel is a JavaScript or image tag that you can copy and paste onto your website's pages.

If you do not have access to either the source code for your website or your tag management solutions, please contact your webmaster to assist you in this.

  1. Go to Facebook Ads Manager | Pixels
  2. Click Create a Pixel
  3. Click Install Pixel Now or Email Pixel Code.
  4. Add the code to your website pages before the ending </head> tag in the page's HTML:
<!-- Facebook Pixel Code -->
// Insert Your Facebook Pixel ID below. 
fbq('init', 'FB_PIXEL_ID');
fbq('track', 'PageView');
<!-- Insert Your Facebook Pixel ID below. --> 
<noscript><img height="1" width="1" style="display:none"
<!-- End Facebook Pixel Code -->

At this point, don't change anything in the code, but verify that your unique pixel ID is showing in place of FB_PIXEL_ID as seen above. The code begins with a HTML comment <!-- Facebook Pixel Code --> and ends with a <!-- End Facebook Pixel Code -->.

If your site using a global include file such as header.php you should add it to this file. You do not have to place the code in the page header, however doing so improves the quality of activity sent to Facebook.

Verify the Pixel

Now verify your pixel works:

  1. Get FB Pixel Helper.
  2. Open a page on your site where you added the pixel.
  3. Click the Pixel Helper icon in your browser's toolbar.

A dialog appears for Pixel Helper. If your new pixel works, you see the message pixel found on .... where the location is the URL for the page you open. After about 15 minutes you can also verify the pixel's data in Facebook Ads Manager. Your pixel status is Active and an Activity chart appears:

If the Status column for your pixel reads Unverified and the Activity chart is empty, review the steps above and contact your webmaster for help.

Add a Pixel to Your Ad

After you add the pixel to your site, you're ready to associate it with your new or existing Facebook Ad.

Next Steps

At this point you can read on and learn about pixel events which are visitor actions on your website you can track with the pixel. You can also start using the pixel with other advertising products such as:

  • Dynamic Product Ads – Track events on your website and optimize display of items from your product catalog in Facebook Ads.
  • Website Custom Audiences – Build targeted segments of your website visitors based on the pages they visit or the actions they take on your website for usage in your Facebook Ads.
  • Conversion Tracking – Use Facebook pixel's standard events or custom conversions to track the actions your visitors take that you care about for usage in conversion tracking and optimization.

View Facebook Pixel Implementation Samples

How Events Work

Events are the actions you want to track on your website. These actions can then be used to build Custom Audiences or custom conversions. In doing so, you can expand reach for your businesses by re-engaging your visitors, finding similar Facebook users as your most valuable customers, measuring how well an ad converts to actions on your website, or optimizing your ads to result in actions on your website.

There are two major types of events:

  • Standard Events – These are predefined events that automatically work for Custom Audiences, custom conversions, conversion tracking, and conversion optimization once you add the events to your website's pages. There are nine of them which represent the most common ways advertisers choose to measure success and optimize ads.

  • Custom Events – If there are unique actions you want to track on your site, you or a developer can create custom events. Using these custom events, you can then build Custom Audiences or custom conversions. Custom conversions can then be used for conversion tracking and optimization.

Next Steps

Now that you have the pixel installed and verified, you can:

  • Create a Custom Audience – Segment the visitors to your site based on pages visited or actions taken, or just build an audience of everyone. You can use these Custom Audiences to re-engage users with targeted ads, or you can let Facebook find new users that are like this Custom Audience.

  • Create a Custom Conversion – Track actions taken by your website visitors that viewed or clicked on Facebook Ads. The actions are based on URLs visited or either standard or custom events triggered. You can then see these conversions in your reporting, or you can choose to optimize your ads for them.

Create Custom Audiences and Custom Conversion