Conversion Tracking

You can use the Facebook pixel to track your website visitors' actions. This is called conversion tracking. Tracked conversions appear in the Facebook Ads Manager and the Facebook Analytics dashboard, where they can be used to analyze the effectiveness of your conversion funnel and to calculate your return on ad investment. You can also use tracked conversions to define custom audiences for ad optimization and dynamic ad campaigns. Once you have defined custom audiences, we can use them to identify other Facebook users who are likely to convert and target them with your ads.

There are three ways to track conversions with the pixel:

  • standard events, which are visitor actions that we have defined and that you report by calling a pixel function
  • custom events, which are visitor actions that you have defined and that you report by calling a pixel function
  • custom conversions, which are visitor actions that are tracked automatically by parsing your website's referrer URLs

Requirements

The pixel's base code must already be installed on every page where you want to track conversions.

Standard Events

Standard events are predefined visitor actions that correspond to common, conversion-related activities, such as searching for a product, viewing a product, or purchasing a product. Standard events support parameters, which allow you to include an object containing additional information about an event, such as product IDs, categories, and the number of products purchased.

Tracking Standard Events

All standard events are tracked by calling the pixel's fbq('track') function, with the event name, and (optionally) a JSON object as its parameters. For example, here's a function call to track when a visitor has completed a purchase event, with currency and value included as a parameter:

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

If you called that function, it would be tracked as a purchase event in the Events Manager:

You can call the fbq('track') function anywhere between your web page's opening and closing <BODY> tags, either when the page loads, or when a visitor completes an action, such as clicking a button.

For example, if you wanted to track a standard purchase event after a visitor has completed the purchase, you could call the fbq('track') function on your purchase confirmation page, like this:

<body>
  ...
  <script>
    fbq('track', 'Purchase', {currency: "USD", value: 30.00});
  </script>
  ...
</body>

If instead you wanted to track a standard purchase event when the visitor clicks a purchase button, you could tie the fbq('track') function call to the purchase button on your checkout page, like this:

<button id="addToCartButton">Purchase</button>
<script type="text/javascript">
  $('#$addToCartButton').click(function() {
    fbq('track', 'Purchase', {currency: "USD", value: 30.00});
  });
</script>

Note that the example above uses jQuery to trigger the function call, but you could trigger the function call using any method you wish.

Standard Events

You can use the fbq('track') function to track the following standard events. Standard events also support parameter objects with specific object properties, which allow you to include detailed information about an event.

Event NameEvent DescriptionObject Properties

AddPaymentInfo

When payment information is added in the checkout flow.

A person clicks on a save billing information button.

content_category, content_ids, contents, currency, value

None required.

AddToCart

When a product is added to the shopping cart.

A person clicks on an add to cart button.

content_ids, content_name, content_type, contents, currency, value

None required.

Required for Dynamic Ads: content_ids, content_type, and contents

AddToWishlist

When a product is added to a wishlist.

A person clicks on an add to wishlist button.

content_name, content_category, content_ids, contents, currency, value

None required.

CompleteRegistration

When a registration form is completed.

A person submits a completed subscription or signup form.

content_name, currency, status, value

None required.

Contact

When a person initiates contact with your business via telephone, SMS, email, chat, etc.

A person submits a question about a product.
None required.

CustomizeProduct

When a person customizes a product.

A person selects the color of a t-shirt.
None required.

Donate

When a person donates funds to your organization or cause.

A person adds a donation to the Humane Society to their cart.
None required.

FindLocation

When a person searches for a location of your store via a website or app, with an intention to visit the physical location.

A person wants to find a specific product in a local store.
None required.

InitiateCheckout

When a person enters the checkout flow prior to completing the checkout flow.

A person clicks on a checkout button.

content_category, content_ids, contents, currency, num_items, value

None required.

Lead

When a sign up is completed.

A person clicks on pricing.

content_category, content_name, currency, value

None required.

PageView

This is the default pixel tracking page visits.

A person lands on your website pages.
None required.

Purchase

When a purchase is made or checkout flow is completed.

A person has finished the purchase or checkout flow and lands on thank you or confirmation page.

content_ids, content_name, content_type, contents, currency, num_items, value

Required: currency and value

Required for Dynamic Ads: content_ids, content_type, and contents

Schedule

When a person books an appointment to visit one of your locations.

A person selects a date and time for a dentist appointment.
None required.

Search

When a search is made.

A person searches for a product on your website.

content_category, content_ids, contents, currency, search_string, value

None required.

StartTrial

When a person starts a free trial of a product or service you offer.

A person selects a free week of your game.

currency, predicted_ltv, value

None required.

SubmitApplication

When a person applies for a product, service, or program you offer.

A person applies for a credit card, educational program, or job.
None required.

Subscribe

When a person applies to a start a paid subscription for a product or service you offer.

A person subscribes to your streaming service.

currency, predicted_ltv, value

None required.

ViewContent

When a key page is viewed such as a product page.

A person lands on a product details page.

content_ids, content_name, content_type, contents, currency, value

None required.

Required for Dynamic Ads: content_ids, content_type, and contents

Custom Events

If our predefined standard events aren't suitable for your needs, you can track your own custom events, which also can be used to define custom audiences for ad optimization. Custom events also support parameters, which you can include to provide additional information about each custom event.

Tracking Custom Events

You can track custom events by calling the pixel's fbq('trackCustom') function, with your custom event name and (optionally) a JSON object as its parameters. Just like standard events, you can call the fbq('trackCustom') function anywhere between your webpage's opening and closing <body> tags, either when your page loads, or when a visitor performs an action like clicking a button.

For example, let's say you wanted to track visitors who share a promotion in order to get a discount. You could track them using a custom event like this:

fbq('trackCustom', 'ShareDiscount', {promotion: 'share_discount_10%'});

Custom event names must be strings, and cannot exceed 50 characters in length.

Custom Conversions

Each time the pixel loads, it automatically calls fbq('track', 'PageView') to track a PageView standard event. PageView standard events record the referrer URL of the page that triggered the function call. You can use these recorded URLs in the Events Manager to define visitor actions that should be tracked.

For example, let's say that you send visitors who subscribe to your mailing list to a thank you page. You could set up a custom conversion that tracks website visitors who have viewed any page that has /thank-you in its URL. Assuming your thank you page is the only page with /thank-you in its URL, and you've installed the pixel on that page, anyone who views it will be tracked using that custom conversion.

Once tracked, custom conversions can be used to optimize your ad campaigns, to define custom audiences, and to further refine custom audiences that rely on standard or custom events.

Since custom conversions rely on complete or partial URLs, you should make sure that you can define visitor actions exclusively based on unique strings in your website URLs.

Creating Custom Conversions

Custom conversions are created entirely within the Events Manager. Refer to our Advertiser Help document to learn how.

Parameters

Parameters are optional, JSON-formatted objects that you can include when tracking standard and custom events. They allow you to provide additional information about your website visitors' actions. Once tracked, parameters can be used to further define any custom audiences you create.

To include a parameter object with a standard or custom event, format your parameter data as an object using JSON, then include it as the third function parameter when calling the fbq('track') or fbq('trackCustom') functions.

For example, let's say you wanted to track a visitor who purchased multiple products as a result of your promotion. You could do this:

fbq('track', 'Purchase',
  // begin parameter object data
  {
    value: 115.00,
    currency: 'USD',
    contents: [
      {
        id: '301',
        quantity: 1,
        item_price: 85.00
      },
      {
        id: '401',
        quantity: 2,
        item_price: 15.00
      }],
    content_type: 'product'
  }
  // end parameter object data
);

Note that if you want to use data included in event parameters when defining custom audiences, key values must not contain any spaces.

Object Properties

You can include the following predefined object properties with any custom events, and any standard events that support them. Format your parameter object data using JSON.

Property KeyValue TypeParameter Description

content_category

String

Category of the page/product.

content_ids

Array of integers or strings

Product IDs associated with the event, such as SKUs (e.g. ['ABC123', 'XYZ789']).

content_name

String

Name of the page/product.

content_type

String

Either product or product_group based on the content_ids or contents being passed. If the IDs being passed in content_ids or contents parameter are IDs of products then the value should be product. If product group IDs are being passed, then the value should be product_group.

contents

Array of objects

An array of JSON objects that contains the International Article Number (EAN) when applicable, or other product or content identifier(s) associated with the event as well as quantities and prices of the products. id, quantity, and item_price are the required fields. e.g. [{'id': 'ABC123', 'quantity': 2, 'item_price': 5.99}, {'id': 'XYZ789', 'quantity': 2, 'item_price': 9.99}]. Note that item_price is the price of a single item, not cumulative price.

currency

String

The currency for the value specified.

num_items

Integer

Used with InitiateCheckout event. The number of items when checkout was initiated.

predicted_ltv

Integer, float

Predicted lifetime value of a subscriber as defined by the advertiser and expressed as an exact value.

search_string

String

Used with the Search event. The string entered by the user for the search.

status

Boolean

Used with the CompleteRegistration event, to show the status of the registration.

value

Integer or float

The value of a user performing this event to the business.

Custom Properties

If our predefined object properties don't suit your needs, you can include your own, custom properties. Custom properties can be used with both standard and custom events, and can help you further define custom audiences.

For example, let's say you wanted to track a visitor who purchased multiple products after having first compared them to other products. You could do this:

fbq('track', 'Purchase',
  // begin parameter object data
  {
    value: 115.00,
    currency: 'USD',
    contents: [
      {
        id: '301',
        quantity: 1,
        item_price: 85.00
      },
      {
        id: '401',
        quantity: 2,
        item_price: 15.00
      }],
    content_type: 'product',
    compared_product: 'recommended-banner-shoes'  // custom property
  }
  // end parameter object data
);

Next Steps

Now that you're tracking conversions, we recommend that you use them to define custom audiences, so you can optimize your ads for website conversions.