npm package: @managed-components/facebook-pixel
Description: Find out more about Managed Components [here](https://blog.cloudflare.com/zaraz-open-source-managed-components-and-webcm/) for inspiration and motivation details.
Author: Cloudflare Managed Components Team
Latest version: 1.0.13

# Facebook Pixel Managed Component

Find out more about Managed Components [here](https://blog.cloudflare.com/zaraz-open-source-managed-components-and-webcm/) for inspiration and motivation details.

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->

[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-)

<!-- ALL-CONTRIBUTORS-BADGE:END -->

[![Released under the Apache license.](https://img.shields.io/badge/license-apache-blue.svg)](./LICENSE)
[![PRs welcome!](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](./CONTRIBUTING.md)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

## 🚀 Quickstart local dev environment

1. Make sure you're running node version >=17.
2. Install dependencies with `npm i`
3. Run unit test watcher with `npm run test:dev`

## ⚙️ Tool Settings

> Settings are used to configure the tool in a Component Manager config file

### Pixel ID `string` _required_

`property` is a long number that identifies your Facebook Ads account. You can obtain it from the [Events Manager](https://www.facebook.com/events_manager2/) underneath your site name.

### Conversion API Access Token _required_

`accessToken` is a string used to authenticate when sending server side events in your name. You can obtain it [following the information here](https://developers.facebook.com/docs/marketing-api/conversions-api/get-started#access-token).

### Test Event Code

`testKey` is used to test your app or web browser events using test events tool [Learn more](https://business.facebook.com/business/help/2040882565969969?id=1205376682832142)

## 🧱 Fields Description

> Fields are properties that can/must be sent with certain events

### Facebook Event Name `string` _required_

`ev` can be \"PageView\", \"Contact\", \"Add to Cart\" one of [the standard Facebook events](https://developers.facebook.com/docs/analytics/send_data/events/#standard), or a custom name.

### Predicted Lifetime Value `number`

`predicted_ltv` is the predicted lifetime value of a subscriber as defined by the advertiser and expressed as an exact value.

### Status `boolean`

`status` can be used with the CompleteRegistration event, to show the status of the registration.

### Value `number`

`value` represents the value of a user performing this event to the business

### Email `string`

`em` user email

### Phone Number `string`

`ph` remove symbols, letters, and any leading zeros. Phone numbers must include a country code to be used for matching (e.g., the number 1 must precede a phone number in the United States). Always include the country code as part of your customers' phone numbers, even if all of your data is from the same country.

### First Name `string`

`fn` using Roman alphabet a-z characters is recommended. Lowercase only with no punctuation.

### Last Name `string`

`ln` using Roman alphabet a-z characters is recommended. Lowercase only with no punctuation.

### Date of Birth `string`

`db` accepts the YYYYMMDD format accommodating a range of month, day and year combinations, with or without punctuation.

### Gender `string`

`ge` can be an initial in lowercase.

### City `string`

`ct` using Roman alphabet a-z characters is recommended. Lowercase only with no punctuation, no special characters, and no spaces.

### State `string`

`st` use the [2-character ANSI abbreviation code](https://en.wikipedia.org/wiki/Federal_Information_Processing_Standard_state_code) in lowercase. Normalize states outside the U.S. in lowercase with no punctuation, no special characters, and no spaces.

### Zip Code `string`

`zp` use lowercase with no spaces and no dash. Use only the first 5 digits for U.S. zip codes. Use the area, district, and sector format for the UK.

### Country `string`

`country` use the lowercase, 2-letter country codes in [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). \n **Important Note:** Always include your customers' countries’ even if all of your country codes are from the same country. We match on a global scale, and this simple step helps us match as many people as possible from your list.

### External ID `string`

`external_id` any unique ID from the advertiser, such as loyalty membership IDs, user IDs, and external cookie IDs

### Subscription ID `string`

`subscription_id` the subscription ID for the user in this transaction; it is similar to the order ID for an individual product.

### Facebook Login ID `string`

`fb_login_id` is the ID issued by Facebook when a person first logs into an instance of an app. This is also known as [App-Scoped ID](https://developers.facebook.com/docs/messenger-platform/reference/id-matching-api/#aid)

### Lead ID `string`

`lead_id` is the ID associated with a lead generated by [Facebook's Lead Ads](https://developers.facebook.com/docs/marketing-api/guides/lead-ads)

### Data Processing Options `string`

`data_processing_options` holds the processing options you would like Facebook to enable for a specific event or record. If you do not provide a value for Data Processing Options, this field will not be included. Read more about the accepted values in [Data Processing Options](https://developers.facebook.com/docs/marketing-apis/data-processing-options/)

### Data Processing Options Country `integer`

`data_processing_options_country` holds the country that you want to associate with this data processing option. If you do not provide a value for Data Processing Options, this field will not be included. Read more about the accepted values in [Data Processing Options](https://developers.facebook.com/docs/marketing-apis/data-processing-options/)

### Data Processing Options State `integer`

`data_processing_options_country` holds the state that you want to associate to this data processing option. If you set a country, you must also set a state. Otherwise, Facebook will perform geolocation. If you do not provide a value for Data Processing Options, this field will not be included. Read more about the accepted values in [Data Processing Options](https://developers.facebook.com/docs/marketing-apis/data-processing-options/)

## 📝 License

Licensed under the [Apache License](./LICENSE).

## 💜 Thanks

Thanks to everyone contributing in any manner for this repo and to everyone working on Open Source in general.

## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
  <tr>
    <td align="center"><a href="https://github.com/simonabadoiu"><img src="https://avatars.githubusercontent.com/u/1610123?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Simona Badoiu</b></sub></a><br /><a href="https://github.com/managed-components/@managed-components/facebook-pixel/commits?author=simonabadoiu" title="Code">💻</a></td>
    <td align="center"><a href="https://yoavmoshe.com/about"><img src="https://avatars.githubusercontent.com/u/55081?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Yo'av Moshe</b></sub></a><br /><a href="https://github.com/managed-components/@managed-components/facebook-pixel/commits?author=bjesus" title="Code">💻</a></td>
    <td align="center"><a href="https://github.com/jonnyparris"><img src="https://avatars.githubusercontent.com/u/6400000?v=4?s=75" width="75px;" alt=""/><br /><sub><b>Ruskin</b></sub></a><br /><a href="https://github.com/managed-components/@managed-components/facebook-pixel/commits?author=jonnyparris" title="Code">💻</a></td>
  </tr>
</table>

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!