# Migration Guide To Facebook Conversion Connector

## Parameter configuration

The Facebook Conversions export integration setup is as below:

| **Parameter Names** | **Required** | **Notes** |
|  --- | --- | --- |
| `pixel_id` | Yes | The Facebook Pixel ID and obtain it in Facebook Event Manager. It must create via Facebook Offline data source. |
| `access_token` | Yes | The access token and obtain from Facebook Business Manager (Ref here for more info [Get Started - Conversions API - Documentation - Meta for Developers](https://developers.facebook.com/docs/marketing-api/conversions-api/get-started) ) |
| `test_event_code` | No | It’s used for testing purpose only |
| `pre_hashed_columns` | No | List of pre-hashed columns and separated by comma |
| `skip_invalid` | No | Optional parameter to control skip job or not when it handle the invalid records. |


## Query field names mapping

The table below will list the mapping query column between Facebook Offline Conversions export integration and Facebook Conversions integration.

| **Facebook Offline Conversions (Column Name)** | **Facebook Conversions (Column Name)** | **Data Type** | **Required?** | **Notes** |
|  --- | --- | --- | --- | --- |
| event_name | event_name | string | Y |  |
| event_time | event_time | long | Y | Event time in milliseconds and it has occurred within the last 7 days. |
| currency | It moves to attribute of custom_data field | double | N | E.g.,   `"custom_data": {     "currency": "USD",     "value": "142.52",     "content_type": "product",     "contents": [{"id":123, "quantity": 2, "item_price":5.99}],     "order_id": "order_123",     "num_items": "5" }` |
| value | It moves to attribute of custom_data field | long | N | E.g.,   `"custom_data": {     "currency": "USD",     "value": "142.52",     "content_type": "product",     "contents": [{"id":123, "quantity": 2, "item_price":5.99}],     "order_id": "order_123",     "num_items": "5" }` |
| content_type | It moves to attribute of custom_data field | string | N | The supported values are: product or product_group  E.g.,   `"custom_data": {     "currency": "USD",     "value": "142.52",     "content_type": "product",     "contents": [{"id":123, "quantity": 2, "item_price":5.99}],     "order_id": "order_123",     "num_items": "5" }` |
| contents | It moves to attribute of custom_data field | string (Serialized json array of object) | N | E.g.,   `"custom_data": {     "currency": "USD",     "value": "142.52",     "content_type": "product",     "contents": [{"id":123, "quantity": 2, "item_price":5.99}],     "order_id": "order_123",     "num_items": "5" }` |
| custom_data | custom_data | json or string  (Object must be in JSON string format and escape double quote) | N | E.g.   `"custom_data": {     "currency": "USD",     "value": "142.52",     "content_type": "product",     "contents": [{"id":123, "quantity": 2, "item_price":5.99}],     "order_id": "order_123",     "num_items": "5" }` |
| order_id | It moves to attribute of custom_data field | string | N | E.g.,   `"custom_data": {     "currency": "USD",     "value": "142.52",     "content_type": "product",     "contents": [{"id":123, "quantity": 2, "item_price":5.99}],     "order_id": "order_123",     "num_items": "5" }` |
| item_number | It move to attribute of custom_data field with new key num_items | long | N | E.g.,   `"custom_data": {     "currency": "USD",     "value": "142.52",     "content_type": "product",     "contents": [{"id":123, "quantity": 2, "item_price":5.99}],     "order_id": "order_123",     "num_items": "5" }` |
| data_processing_options | data_processing_options | string | N |  |
| data_processing_options_country | data_processing_options_country | long | N |  |
| data_processing_options_state | data_processing_options_state | long | N |  |
| email | em | string | N | The Facebook Offline Conversions output connector can support multiple email column, but Facebook Conversions output connector support only 1 email column |
| phone | ph | string | N | The Facebook Offline Conversions output connector can support multiple phone column, but Facebook Conversions output connector support only 1 phone column |
| gen | ge | string | N |  |
| doby | db | string | N | Merge 3 columns: doby, dobm, dobd to one column db in Facebook Conversions output connector  [Format: YYYYMMDD](https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/customer-information-parameters#db) |
| dobm |  |  |  |  |
| dobd |  |  |  |  |
| ln | ln | string | N |  |
| fn | fn | string | N |  |
| fi |  |  |  | First name initials - Not supported in Facebook Conversions API  refer: [https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/customer-information-parameters](https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/customer-information-parameters) |
| ct | ct | string | N |  |
| st | st | string | N |  |
| zip | zp | string | N |  |
| country | country | string | N |  |
| madid |  |  |  | mobile advertiser ID, the advertising ID from an Android device or the Advertising Identifier (IDFA) from an Apple device.  ***Note:** This parameter is for **app events** only*  refer: [https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/customer-information-parameters](https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/customer-information-parameters) |
| external_id | external_id | string | N |  |
| lead_id | lead_id | long | N |  |
|  | action_source | string | Y | The additional field in Facebook Conversions output connector to indicate the offline event and value must set to physical_store |


## Sample queries


```sql
SELECT
  event_name,
  event_time,
  custom_data,
  data_processing_options,
  data_processing_options_country,
  data_processing_options_state,
  em,
  ph,
  ge,
  db,
  ln,
  fn,
  ct,
  ct,
  st,
  zp,
  country,
  external_id,
  lead_id,
  action_source
FROM
  TABLE_NAME
```