Back to News for Developers

Announcing Facebook Pixel

October 14, 2015ByCecile Ho

Today we're announcing the Facebook pixel, a new way to report and optimize for conversions, build audiences and get rich insights about how people use your website. We're also announcing the availability of custom conversions, a new rule-based method to track and report conversions for your Facebook ads.

Facebook pixel makes things simple for advertisers by combining the functionality of the Conversion Tracking pixels and Custom Audience pixels into a single pixel. You only need to place a single pixel across your entire website to report and optimize for conversions. Since it is built on top of the upgraded Custom Audience pixel, all the features announced in our previous blog post (Announcing Upgrades to Conversion Tracking and Optimization at Facebook) are supported through Facebook pixel as well.

You can use Facebook pixel to track and optimize for conversions by adding standard events (e.g. Purchase) to your Facebook pixel base code on appropriate pages (e.g. purchase confirmation page).

Facebook Pixel BASE Code example

<!-- Facebook Pixel Code --><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');// Insert Your Facebook Pixel ID below. 
fbq('init', '<FB_PIXEL_ID>');
fbq('track', 'PageView');</script>
<!-- Insert Your Facebook Pixel ID below. --> 
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=<FB_PIXEL_ID>&amp;ev=PageView&amp;noscript=1"
/></noscript><!-- End Facebook Pixel Code -->

Custom Conversions

Custom conversions allow you to optimize for and track actions without having to add any extra events to your Facebook pixel base code. You can also optimize for and track actions that are different from the nine standard events.

Optimizing for Conversions Using the Rule Based Custom Conversion

Create a custom conversion you would like to track and optimize for through /customconversions. You'll define your custom conversion by specifying the URL, or part of the URL, that represents your custom conversion in the pixel_rule. (ex: URL contains thankyou.html for a thank-you page after a purchase). Set pixel_id to your Facebook pixel id.

curl \
-F 'name=Example Custom Conversion' \
-F 'pixel_id=<FB_PIXEL_ID>' \
-F 'pixel_rule={"url":{"i_contains": "thankyou.html"}}' \
-F 'custom_event_type=PURCHASE' \
-F 'access_token=<ACCESS_TOKEN>' \
'https://graph.facebook.com/<API_VERSION>/act_<AD_ACCOUNT_ID>/customconversions'

You can then create your campaign using CONVERSIONS objective, and at ad set level, specify the same setting of custom conversion in promoted_object you would like to track and optimize for.

curl \
-F 'name=Example Adset' \
-F 'bid_amount=300' \
-F 'billing_event=IMPRESSIONS' \
-F 'optimization_goal=LINK_CLICKS' \
-F 'status=ACTIVE' \
-F 'daily_budget=2000' \
-F 'campaign_id=<CAMPAIGN_ID>' \
-F 'targeting={
"geo_locations": {"countries": ["US"]},
}' \
-F 'promoted_object={"pixel_id":<FB_PIXEL_ID>,"pixel_rule":{"url":{"i_contains": "thankyou.html"}}, "custom_event_type":"PURCHASE"}' \
-F 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v2.5/act_<AD_ACCOUNT_ID>/adsets

Please note that the maximum number of custom conversions per ad account is 20. Once you create a custom conversion it cannot be deleted.

Read more about Facebook pixel through API here.

Deprecation of Conversion Pixel

The Facebook pixel replaces the existing Conversion Tracking pixel and Custom Audience pixels. Your existing Conversion Tracking pixels and Custom Audience pixels will continue to work as before, but we recommend that advertisers upgrade to the Facebook pixel to take advantage of these new features.

We plan to remove support for existing Conversion Tracking pixels by the second half of 2016. Any account using the Conversion Tracking pixel should transition to the Facebook pixel before then in order to continue using conversion tracking and optimization for their Facebook ads.

To learn more about the Facebook pixel visit our Help Center at facebook.com/help/pixel.