# Facebook Conversionsコネクタへの移行ガイド

## パラメータ設定

Facebook Conversions エクスポート連携の設定は以下の通りです：

| **パラメータ名** | **必須** | **備考** |
|  --- | --- | --- |
| `pixel_id` | Yes | Facebook Pixel IDです。Facebook Event Managerで取得できます。Facebook Offlineデータソース経由で作成する必要があります。 |
| `access_token` | Yes | アクセストークンです。Facebook Business Managerから取得できます（詳細は [Get Started - Conversions API - Documentation - Meta for Developers](https://developers.facebook.com/docs/marketing-api/conversions-api/get-started) を参照してください） |
| `test_event_code` | No | テスト目的でのみ使用されます |
| `pre_hashed_columns` | No | 事前にハッシュ化されたカラムのリストで、カンマ区切りで指定します |
| `skip_invalid` | No | 無効なレコードを処理する際にジョブをスキップするかどうかを制御するオプションパラメータです。 |


## クエリフィールド名のマッピング

以下の表は、Facebook Offline Conversions エクスポート連携と Facebook Conversions 連携の間のクエリカラムのマッピングを示しています。

| **Facebook Offline Conversions（カラム名）** | **Facebook Conversions（カラム名）** | **データ型** | **必須？** | **備考** |
|  --- | --- | --- | --- | --- |
| event_name | event_name | string | Y |  |
| event_time | event_time | long | Y | イベント時間をミリ秒単位で指定し、過去7日以内に発生したものである必要があります。 |
| currency | custom_data フィールドの属性に移動 | double | N | 例：   `"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 | custom_data フィールドの属性に移動 | long | N | 例：   `"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 | custom_data フィールドの属性に移動 | string | N | サポートされる値は：product または product_group  例：   `"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 | custom_data フィールドの属性に移動 | string (シリアライズされたJSONオブジェクト配列) | N | 例：   `"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 または string  (オブジェクトはJSON文字列形式で、ダブルクォートをエスケープする必要があります) | N | 例：   `"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 | custom_data フィールドの属性に移動 | string | N | 例：   `"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 | custom_data フィールドの属性に新しいキー num_items として移動 | long | N | 例：   `"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 | Facebook Offline Conversions 出力コネクタは複数のemailカラムをサポートできますが、Facebook Conversions 出力コネクタは1つのemailカラムのみサポートします |
| phone | ph | string | N | Facebook Offline Conversions 出力コネクタは複数のphoneカラムをサポートできますが、Facebook Conversions 出力コネクタは1つのphoneカラムのみサポートします |
| gen | ge | string | N |  |
| doby | db | string | N | 3つのカラム（doby、dobm、dobd）を1つのカラムdbにマージします（Facebook Conversions 出力コネクタ）  [フォーマット：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 |  |  |  | ファーストネームのイニシャル - Facebook Conversions APIではサポートされていません  参照：[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 |  |  |  | モバイル広告主ID、Androidデバイスからの広告IDまたはAppleデバイスからの広告識別子（IDFA）。  ***注意：** このパラメータは**アプリイベント**のみに使用されます*  参照：[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 | Facebook Conversions 出力コネクタの追加フィールドで、オフラインイベントを示します。値は physical_store に設定する必要があります |


## サンプルクエリ


```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
```