LogoLogo
  • Contributing to RudderStack
  • Destination_Name
  • LICENSE
  • RudderStack Docs
  • docs
    • FAQ
    • Identity Resolution
    • Home
    • cloud-extract-sources
      • ActiveCampaign Source
      • Bing Ads
      • Chargebee
      • Common Settings
      • Facebook Ads
      • Freshdesk
      • Google Ads Source
      • Google Analytics
      • Google Search Console
      • Google Sheets
      • Cloud Extract Sources
      • Intercom v2
      • Intercom
      • Mailchimp
      • Marketo
      • Mixpanel
      • NetSuite
      • Pipedrive
      • QuickBooks
      • Salesforce Pardot
      • Sendgrid Source
      • Stripe Source
      • Xero
      • Zendesk Chat
      • Zendesk
      • hubspot
        • HubSpot Data Model and Schema Information
        • HubSpot
      • salesforce
        • Salesforce
        • Schema Comparison: RudderStack vs. Segment
    • connections
      • Connection Modes: Cloud Mode vs. Device Mode
    • data-governance
      • Data Governance
      • RudderTyper
      • Data Governance API
      • RudderTyper
      • tracking-plans
        • Tracking Plans
        • Tracking Plan Spreadsheet
    • data-warehouse-integrations
      • Amazon Redshift
      • Azure Data Lake
      • Azure Synapse
      • ClickHouse
      • Databricks Delta Lake
      • Google Cloud Storage Data Lake
      • Google BigQuery
      • Identity Resolution
      • Warehouse Destinations
      • Microsoft SQL Server
      • PostgreSQL
      • Amazon S3 Data Lake
      • Snowflake
      • FAQ
      • Warehouse Schema
    • destinations
      • Destinations
      • Webhooks
      • advertising
        • Bing Ads
        • Criteo
        • DCM Floodlight
        • Facebook App Events
        • Facebook Custom Audience
        • Facebook Pixel
        • Google Ads (gtag.js)
        • Google AdWords Enhanced Conversions
        • Google Adwords Remarketing Lists (Customer Match)
        • Advertising
        • LinkedIn Insight Tag
        • Lotame
        • Pinterest Tag
        • Reddit Pixel
        • Snap Pixel
        • TikTok Ads
      • analytics
        • Amplitude
        • AWS Personalize
        • Chartbeat
        • Firebase
        • FullStory
        • Google Analytics 360
        • Google Analytics
        • Heap.io
        • Hotjar
        • Analytics
        • Indicative
        • Keen
        • Kissmetrics
        • Kubit
        • Lytics
        • Mixpanel
        • Pendo
        • PostHog
        • Quantum Metric
        • Singular
        • adobe-analytics
          • Adobe Analytics Heartbeat Measurement
          • Mobile Device Mode Settings
          • Web Device Mode Settings
          • E-commerce Events
          • Adobe Analytics
          • Setting Up Adobe Analytics in RudderStack
        • google-analytics-4
          • Cloud Mode
          • Device Mode
          • Google Analytics 4
          • Setting up Google Analytics 4
        • profitwell
          • ProfitWell
          • Cloud Mode
          • Device Mode
      • attribution
        • Adjust
        • AppsFlyer
        • Branch
        • Attribution
        • Kochava
        • TVSquared
      • business-messaging
        • Business Messaging
        • Intercom
        • Kustomer
        • Slack
        • Trengo
      • continuous-integration
        • Visual Studio App Center
        • Continuous Integration
      • crm
        • Delighted
        • HubSpot
        • CRM
        • Salesforce
        • Variance
        • Zendesk
      • customer-data-platform
        • Customer Data Platform
        • Segment
      • error-reporting
        • Bugsnag
        • Error Reporting
        • Sentry
      • marketing
        • ActiveCampaign
        • AdRoll
        • Airship
        • Appcues
        • Autopilot
        • Blueshift
        • Braze
        • CleverTap
        • Customer.io
        • Gainsight PX
        • Gainsight
        • Marketing
        • Iterable
        • Klaviyo
        • Leanplum
        • Mailchimp
        • Marketo Lead Import
        • Marketo
        • MoEngage
        • Ometria
        • Pardot
        • Post Affiliate Pro
        • Qualtrics
        • SendGrid
        • Salesforce Marketing Cloud
        • Userlist
        • drip
          • Cloud Mode
          • Device Mode
          • Drip
          • Setting Up Drip in RudderStack
      • productivity
        • Google Sheets
        • Productivity
      • storage-platforms
        • Amazon S3
        • DigitalOcean Spaces
        • Google Cloud Storage
        • Storage Platforms
        • Azure Blob Storage
        • MinIO
        • Redis
      • streaming-platforms
        • Amazon EventBridge
        • Amazon Kinesis Firehose
        • Amazon Kinesis
        • Azure Event Hubs
        • BigQuery Stream
        • Confluent Cloud
        • Google Pub/Sub
        • Streaming Platforms
        • Apache Kafka
      • tag-managers
        • Google Tag Manager
        • Tag Managers
      • testing-and-personalization
        • Algolia Insights
        • Candu
        • Google Optimize
        • A/B Testing & Personalization
        • LaunchDarkly
        • Monetate
        • Optimizely Full Stack
        • Optimizely Web
        • Split.io
        • Statsig
        • VWO (Visual Website Optimizer)
    • get-started
      • RudderStack Cloud vs. RudderStack Open Source
      • Glossary
      • Get Started
      • RudderStack Architecture
    • reverse-etl
      • Amazon Redshift
      • Amazon S3
      • ClickHouse
      • FAQ
      • Google BigQuery
      • Reverse ETL
      • PostgreSQL
      • Snowflake
      • common-settings
        • Importing Data using Models
        • Importing Data using Tables
        • Common Settings
        • Sync Modes
        • Sync Schedule
      • features
        • Airflow Provider
        • Features
        • Models
        • Visual Data Mapper
    • rudderstack-api
      • Data Regulation API
      • HTTP API
      • RudderStack API
      • Personal Access Tokens
      • Pixel API
      • Test API
      • api-specification
        • Application Lifecycle Events Specification
        • API Specification
        • Video Events Specification
        • rudderstack-ecommerce-events-specification
          • Browsing
          • Coupons
          • E-Commerce Events Specification
          • Ordering
          • Promotions
          • Reviewing
          • Sharing
          • Wishlist
        • rudderstack-spec
          • Alias
          • Common Fields
          • Group
          • Identify
          • RudderStack Event Specification
          • Page
          • Screen
          • Track
    • rudderstack-cloud
      • Audit Logs
      • Dashboard Overview
      • Destinations
      • RudderStack Cloud
      • Live Events
      • Connection Modes: Cloud Mode vs. Device Mode
      • Sources
      • Teammates (User Management)
      • connections
        • Adding a Destination
        • Connections
    • rudderstack-open-source
      • Control Plane Setup
      • RudderStack Open Source
      • installing-and-setting-up-rudderstack
        • Developer Machine Setup
        • Docker
        • Data Plane Setup
        • Kubernetes
        • Sending Test Events
    • stream-sources
      • App Center
      • AppsFlyer
      • Auth0
      • Braze
      • Customer.io
      • Extole
      • Event Stream Sources
      • Iterable
      • Looker
      • PostHog
      • Segment
      • Shopify
      • Webhook Source
      • rudderstack-sdk-integration-guides
        • Client-side Event Filtering
        • SDKs
        • AMP Analytics
        • Cordova
        • .NET
        • Go
        • Java
        • Node.js
        • PHP
        • Python
        • React Native
        • Ruby
        • Rust
        • Unity
        • SDK FAQs
        • rudderstack-android-sdk
          • Adding Application Class
          • Flushing Events Periodically
          • Android
        • rudderstack-flutter-sdk
          • Flutter SDK v1
          • Flutter v2
          • Flutter
        • rudderstack-ios-sdk
          • iOS
          • tvOS
          • watchOS
        • rudderstack-javascript-sdk
          • Data Storage in Cookies
          • Detecting Ad-blocked Pages
          • JavaScript
          • JavaScript SDK Enhancements
          • JavaScript SDK FAQs
          • Querystring API
          • Quick Start Guide
          • Version Migration Guide
          • consent-managers
            • Consent Managers
            • OneTrust
    • transformations
      • Access Token
      • FAQ
      • Transformations
      • Transformations API
    • user-guides
      • User Guides
      • administrators-guide
        • Troubleshooting Guide
        • Alerting Guide
        • Bucket Configuration Settings for Event Backups
        • Configuration Parameters
        • Event Replay
        • High Availability
        • Horizontal Scaling
        • Administrator's Guides
        • Infrastructure Provisioning
        • Monitoring and Metrics
        • Okta SSO Setup
        • OneLogin SSO Setup
        • RudderStack Grafana Dashboard
        • Software Releases
      • how-to-guides
        • How to Use Custom Domains
        • How to Develop Integrations for RudderStack
        • How to Configure a Destination via the Event Payload
        • How to Filter Events using Different Methods
        • How to Filter Selective Destinations
        • How to Submit a Pull Request for a New Integration
        • How-to Guides
        • How to Debug Live Destination Events
        • How to Use AWS Lambda Functions with RudderStack
        • create-a-new-destination-transformer-for-rudder
          • Best Practices for Coding Transformation Functions in JavaScript
          • How to Create a New Destination Transformation for RudderStack
        • implement-native-js-sdk-integration
          • How to Add a Device Mode SDK to RudderStack JavaScript SDK
          • How to Implement a Native JavaScript SDK Integration
        • rudderstack-jamstack-integration
          • How to Integrate RudderStack with Your JAMstack Site
          • How to Integrate Rudderstack with Your Angular App
          • How to Integrate Rudderstack with Your Astro Site
          • How to Integrate Rudderstack with Your Eleventy Site
          • How to Integrate Rudderstack with Your Ember.js App
          • How to Integrate Rudderstack with a Gatsby Website
          • How to Integrate Rudderstack with a Hugo Site
          • How to Integrate Rudderstack with Your Jekyll Site
          • How to Integrate Rudderstack with Your Next.js App
          • How to Integrate Rudderstack with Your Nuxt.js App
          • How to Integrate Rudderstack with Your Svelte App
          • How to Integrate Rudderstack with Your Vue App
      • migration-guides
        • Migrating from Blendo to RudderStack
        • Migrating Your Warehouse Destination from Segment to RudderStack
        • Migration Guides
        • Migrating from Segment to RudderStack
  • src
    • @rocketseat
      • gatsby-theme-docs
        • text
          • Home
Powered by GitBook
On this page
  • Getting started
  • Connection settings
  • Event settings
  • PII properties settings
  • Other settings
  • Client-side event filtering
  • Web SDK settings
  • Identify
  • Page
  • Track
  • Standard events
  • Other standard events
  • Legacy events
  • Custom events
  • Deduplication
  • Timestamps
  • FAQ
  • Contact us

Was this helpful?

  1. docs
  2. destinations
  3. advertising

Facebook Pixel

Step-by-step guide to send event data from RudderStack to Facebook Pixel.

PreviousFacebook Custom AudienceNextGoogle Ads (gtag.js)

Last updated 3 years ago

Was this helpful?

is a simple JavaScript snippet that you can add to your website and track visitor activity as well as other important metrics required to build effective marketing and advertising campaigns.

RudderStack leverages the for sending server-side events to this destination.

Find the open-source transformer code for this destination in our .

Getting started

Before configuring Facebook Pixel as a destination in RudderStack, verify if the source platform is supported by Facebook Pixel, by referring to the table below:

Connection Mode

Web

Mobile

Server

Device mode

Supported

-

-

Cloud mode

Supported

Supported

Supported

To know more about the difference between cloud mode and device mode in RudderStack, refer to the guide.

Once you have confirmed that the source platform supports sending events to Google Adwords Remarketing Lists, follow these steps:

  1. From your , add the source. Then, from the list of destinations, select Facebook Pixel.

  2. Assign a name to your destination and click on Next.

Connection settings

To successfully configure Facebook Pixel as a destination, you will need to configure the following settings:

The following sections explain these settings in more detail.

  • Facebook Pixel ID: Enter your Facebook Pixel ID. This is required for sending events via both cloud and device modes.

  • Business Access Token: Enter your Facebook business access token required to send the events via the cloud mode.

Event settings

  • Map Categories to Facebook Content Types: This option lets you specify the category fields to specific Facebook content type.

  • Enable Standard Event (PageView) for all Page and Screen Calls: If this setting is enabled, RudderStack sets pageview as a standard event for all the page and screen calls.

  • Map your events with Facebook Standard Events: This option lets you map your events to the standard events defined by Facebook.

  • Standard Events custom properties: For the standard events, some predefined properties are taken by Facebook. If you want to send more properties for your events, mention those properties in this field.

  • Value Field Identifier: You can set this field to properties.price or properties.value. RudderStack will then assign this to the value field of the Facebook payload.

PII properties settings

  • Blacklist PII Properties: The PII properties mentioned in this field will not be sent to Facebook if Blacklist PII Hash Property is not enabled. If it is enabled, the properties will be SHA256-hashed and sent to Facebook. The properties listed below are the default blacklisted properties.

Default blacklisted PII

email

firstName

lastName

firstname

lastname

first_name

last_name

gender

city

country

phone

state

zip

birthday

If you want to send any of the above properties hashed by SHA256, you need to enter the property name in the Blacklist PII Properties field and enable the Blacklist PII Hash Property toggle.

  • Whitelist PII Properties: The PII properties mentioned in this field will be sent to Facebook if they are present in the properties of the events. This is only necessary for properties that match the Default Blacklisted PII properties listed above.

Other settings

  • Limited Data Usage: If enabled, RudderStack will take the data processing information from the payload and send it to Facebook. The data in the RudderStack payload should be as shown below:

"context": {
  "dataProcessingOptions": [
    [
      "LDU"
    ],
    1,
    1000
  ],
  "fbc": "fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890",
  "fbp": "fb.1.1554763741205.234567890",
  "fb_login_id": "fb_id",
  "lead_id": "lead_id",
  "device": {
    "id": "df16bffa-5c3d-4fbb-9bce-3bab098129a7R",
    "manufacturer": "Xiaomi",
    "model": "Redmi 6",
    "name": "xiaomi"
  },
  "network": {
    "carrier": "AirCarrier"
  },
  "os": {
    "name": "android",
    "version": "8.1.0"
  },
  "screen": {
    "height": "100",
    "density": 50
  },
  "traits": {
    "email": "john@example.com",
    "anonymousId": "c82cbdff-e5be-4009-ac78-cdeea09ab4b1"
  }
}
  • Use as Test Destination: Enable this setting if you are using this destination for testing purposes and enter the Test Event Code. This code can be found in your Facebook Pixel dashboard.

Client-side event filtering

Web SDK settings

  • Use Updated Mapping: If this setting is disabled, RudderStack will send the identify traits as received. If this setting is enabled, RudderStack takes the following example identify traits:

{
  firstName: "Alex",
  lastName: "Keener",
  email: "alex@example.com",
  phone: "12345678910",
  gender: "Male",
  birthday: "01012001",
  city: "New Orleans",
  country: "USA",
  zip: "90009",
  state: "Louisiana",
  foo: "bar",
}

RudderStack then changes the traits as shown below, before sending them to Facebook:

{
  fn: "Alex",
  ln: "Keener",
  em: "alex@example.com",
  ph: "12345678910",
  ge: "Male",
  db: "01012001",
  ct: "New Orleans",
  country: "USA",
  zp: "90009",
  state: "Louisiana",
  foo: "bar"
}
  • Legacy Conversion Pixel IDs: With this setting, you can send specific events to a legacy conversion Pixel by specifying the event-Pixel ID mapping. Note that this option is available only when sending events via the device mode.

  • Use device-mode to send events: Enable this setting to send events from the web SDK to Facebook Pixel via the device mode.

  • Finally, click on Next to complete the configuration.

Identify

In Facebook Pixel, the immediate updating of user properties via the identify call is not supported. If the Enable Advanced Matching is turned on in the dashboard, then the identify call will update Facebook Pixel with the user information.

The following snippet highlights the use of the identify call:

rudderanalytics.identify("userId", userVars) // userVars is a JSON object

Page

When you make the page call, RudderStack sends the data to Facebook Pixel with the event type as pageView. You can also pass properties to page - RudderStack automatically sends these properties along with the event ID to Pixel.

A sample page call is as shown:

rudderanalytics.page()

Track

The track call lets you track custom events as they occur in your web application.

A sample call looks like the following code snippet:

rudderanalytics.track("Product Added", {
  order_ID: "123",
  category: "boots",
  product_name: "yellow_cowboy_boots",
  price: 99.95,
  currency: "EUR",
  revenue: 2000,
  value: 3000,
  checkinDate: "Thu Mar 24 2018 17:46:45 GMT+0000 (UTC)",
})

In addition to the above call, a contentType in the integrations options can be available. If present, it will precede the default value or dashboard settings of contentType.

rudderanalytics.track(
  "Product Added",
  {
    order_ID: "123",
    category: "boots",
    product_name: "yellow_cowboy_boots",
    price: 99.95,
    currency: "EUR",
    revenue: 2000,
    value: 3000,
    checkinDate: "Thu Mar 24 2018 17:46:45 GMT+0000 (UTC)",
  },
  {
    "Facebook Pixel": { contentType: "mycustomtype" },
  }
)

A string is the only valid data type for the category field. However, you can pass an array of string values which will be concatenated using a delimiter (,) before sending the events.

Standard events

In the dashboard, you have the option to map your events to standard Facebook events. RudderStack maps the events in the code and sends them to Facebook pixel as the standard event as specified. The properties will be sent according to what the standard event requires.

The mapping is done as follows in RudderStack:

Rudder Event
Facebook Standard Event

Product List Viewed

ViewContent

Product Viewed

ViewContent

Product Added

AddToCart

Order Completed

Purchase

Products Searched

Search

Checkout Started

InitiateCheckout

In Pixel, a currency for Purchase events is required to be specified. If not provided the default will be set to USD.

Other standard events

If you map your event to any of the following Standard Events listed below, then RudderStack will treat it as an Other Standard Event. For any properties you would like to send with the other standard event you must specify them in the Standard Events custom properties settings field.

"AddToWishlist"
"AddPaymentInfo"
"Lead"
"CompleteRegistration"
"Contact"
"CustomizeProduct"
"Donate"
"FindLocation"
"Schedule"
"StartTrial"
"SubmitApplication"
"Subscribe"

Legacy events

In the dashboard, the legacy conversion Pixel IDs can be filled. The events which appear in the mapping are sent to Pixel with the mapped Pixel ID. The conversion events only support currency and value as their event properties.

This is only available for device mode.

Custom events

Custom events are used to send any event that does not appear in any of the mappings.

Deduplication

Facebook Pixel allows you to send events via your web browser and your server via the Conversion API. Depending on how you send your events, with this duel set-up, redundant events may be received by Facebook. Therefore, to help get accurate representation of your data, Facebook tries to deduplicate events coming in.

event_id method (Recommended)

Facebook's (and RudderStack's) recommended form of deduplication is to leverage the event_name and event_id properties. When two events coming into Facebook meet the following criteria, they will be deduplicated.

  • They are sent within 48 hours of each other

  • They are received by the same Facebook Pixel ID

  • They have the same event_name i.e. Purchase etc.

  • They have the same event_id

    • The event_id must be unique to that specific event and the same for both of the events coming from the Pixel and Conversion API

    • For example: the event_id could be the purchase order number etc.

If you don't set the event_id, RudderStack will use messageId to map to Facebook's eventId.

The event_name will be picked up from the name of the event.

fbp and external_id method (Not Recommended)

For this approach, it is necessary to send an event, first from the browser, then from the server. Both events must have the same event_name, and the same fbp parameter and the same external_id. If the browser event is received before the server event and both events have the same event_name and the same fbp and external_id, then the server event will be discarded. Below are a few shortcomings for this deduplication method.

  • It will always discard the server event is Facebook identifies a redundant event.

  • This method only works for deduplicating events sent first from the browser and then the server.

  • There will be no deduplication if two consecutive browser events with the same information are sent to Facebook. The same is true if two server events with the same information is sent to Facebook

RudderStack maps the event_name from whatever the name of the event that is being sent is. The fbp parameter is taken from the context.fbp key-value pair. Finally, the external_id will just be the userId or anonymousId (if userId is not present).

Timestamps

Facebook Pixel uses ISO 8601 timestamp without the timezone information.

Facebook expects them to be sent in the following format:

"checkinDate", "checkoutDate", "departingArrivalDate", "departingDepartureDate", "returningArrivalDate", "returningDepartureDate", "travelEnd", "travelStart"

FAQ

Where can I find the Pixel ID?

To get your Pixel ID, go to your Facebook Ads Manager account. On the left navigation bar, select Business Tools, and click on Events Manager under Manage Business.

In the Data Sources, you should be able to see your Pixel ID underneath your site name.

Where can I find the Business Access Token?

In order to use the Facebook Conversions API, you need to generate an access token. We recommend using the Facebook Events Manager to do so, by following these steps:

  • Choose the relevant Facebook Pixel and click on the Settings tab.

  • In the Conversions API section, click on Generate access token under the Set up manually section, as shown:

Can I hash my user data before sending it to RudderStack?

Yes. Facebook Pixel requires all user data, data coming from context.traits, to be hashed. This includes email, phone, birthday, address, etc. By default, RudderStack will automatically hash all of the necessary properties for you. However, if you would like to hash these traits before sending to RudderStack then you need to add this code to the event.

rudderanalytics.track(
  "some_event_name",
  { some_properties },
  {
    integrations: {
      "Facebook Pixel": {
        hashed: true,
      },
    },
  }
)

The integrations object with these key-values will tell RudderStack not to hash the traits in context.traits because they are already hashed. Otherwise, RudderStack will hash your data again and Facebook will not be able to match the traits. Please keep in mind that Facebook will not accept un-hashed data.

Contact us

For more information on obtaining your Facebook Pixel ID and Business Access Token, refer to the section below.

The context.dataProcessingOptions will be mapped to data_processing_options in Facebook as is mentioned in the .

RudderStack supports specifying which events should be discarded or allowed to flow through, when sending events via the device mode. For more information, refer to the documentation.

Refer to the guide for more information.

For more information on Facebook Deduplication, you can refer to .

You can set the event_id in traits , context.traits or properties object as a unique identifier. This works for the as well as .

For more information regarding the logic behind the event_id deduplication, read .

For more information regarding the logic behind the fbp and external_id deduplication, read .

For more information on how to use this access token, or to generate your access token via your own app, check out Facebook's .

For queries on any of the sections covered in this guide, you can or start a conversation in our community.

Facebook developer docs
Client-side Event Filtering
E-Commerce Event Specifications
this article
cloud mode
device mode
this article
this article
developer documentation
contact us
Slack
FAQ
Facebook Pixel
Conversions API
GitHub repository
RudderStack Connection Modes
RudderStack dashboard
Connection settings
Connection settings
Connection settings
Connection settings
Connection settings