はじめに
こんにちは、ユーゴです。今回は、FacebookのマーケティングAPIを叩いていた時に、調べてもなかなか分からなかった情報を載せておきます。
前提
FacebookのGraph APIは以下のように叩く。
https://graph.facebook.com/{バージョン}/{ID}
バージョン:「v20.0」というように指定。2024/09/27現在は20.0である。
ID:広告アカウントID、キャンペーンID、広告ID、ReportRunIDなどいろんなIDを入れる。
必要に応じて、クエリ文字にaccess_tokenなども入れる
問題
クエリに「fields」を指定することがある。特に、Ads AccountのInsightを使う時、どの項目を取得するか指定する必要があります。しかし、これが調べてもなかなか出てきませんでした。
結論
以下の「summary」というレスポンスから逆算して、検討をつけました。
https://developers.facebook.com/docs/marketing-api/reference/ad-account/insights/?locale=ja_JP#--
ひたすらfieldsにパラメータを指定し続けて、確認して行きました。
うまく行ったのは、以下の通りです。
- account_currency
- account_id
- account_name
- action_values
- actions
- ad_click_actions
- ad_id
- ad_impression_actions
- ad_name
- adset_id
- adset_name
- attribution_setting
- auction_bid
- auction_competitiveness
- auction_max_competitor_bid
- buying_type
- campaign_id
- campaign_name
- canvas_avg_view_percent
- canvas_avg_view_time
- catalog_segment_actions
- catalog_segment_value
- catalog_segment_value_mobile_purchase_roas
- catalog_segment_value_omni_purchase_roas
- catalog_segment_value_website_purchase_roas
- clicks
- conversion_values
- conversions
- converted_product_quantity
- converted_product_value
- cost_per_15_sec_video_view
- cost_per_2_sec_continuous_video_view
- cost_per_action_type
- cost_per_ad_click
- cost_per_conversion
- cost_per_dda_countby_convs
- cost_per_inline_link_click
- cost_per_inline_post_engagement
- cost_per_one_thousand_ad_impression
- cost_per_outbound_click
- cost_per_thruplay
- cost_per_unique_action_type
- cost_per_unique_click
- cost_per_unique_conversion
- cost_per_unique_inline_link_click
- cost_per_unique_outbound_click
- cpc
- cpm
- cpp
- created_time
- ctr
- date_start
- date_stop
- dda_countby_convs
- dda_results
- frequency
- full_view_impressions
- full_view_reach
- impressions
- inline_link_click_ctr
- inline_link_clicks
- inline_post_engagement
- instagram_upcoming_event_reminders_set
- instant_experience_clicks_to_open
- instant_experience_clicks_to_start
- instant_experience_outbound_clicks
- interactive_component_tap
- mobile_app_purchase_roas
- objective
- optimization_goal
- outbound_clicks
- outbound_clicks_ctr
- purchase_roas
- qualifying_question_qualify_answer_rate
- reach
- shops_assisted_purchases
- social_spend
- spend
- updated_time
- video_30_sec_watched_actions
- video_avg_time_watched_actions
- video_continuous_2_sec_watched_actions
- video_p100_watched_actions
- video_p25_watched_actions
- video_p50_watched_actions
- video_p75_watched_actions
- video_p95_watched_actions
- video_play_actions
- video_play_curve_actions
- video_play_retention_0_to_15s_actions
- video_play_retention_20_to_60s_actions
- video_play_retention_graph_actions
- video_time_watched_actions
- website_ctr
- website_purchase_roas
jsonで日本語訳の対応も置いておきます。自前の翻訳なので、責任は負い兼ねます。
対応リスト
{
"account_currency": "通貨",
"account_id": "アカウントID",
"account_name": "アカウント名",
"action_values": "アクション価値",
"actions": "アクション",
"ad_click_actions": "広告内の全クリックアクション",
"ad_id": "広告ID",
"ad_impression_actions": "広告のインプレッションアクション",
"ad_name": "広告名",
"adset_id": "広告セットID",
"adset_name": "広告セット名",
"attribution_setting": "アトリビューション設定",
"auction_bid": "入札額",
"auction_competitiveness": "オークションの競争度",
"auction_max_competitor_bid": "競合広告主の入札最高額",
"buying_type": "購入タイプ",
"campaign_id": "キャンペーンID",
"campaign_name": "キャンペーン名",
"canvas_avg_view_percent": "インスタントエクスペリエンスの平均視聴割合",
"canvas_avg_view_time": "インスタントエクスペリエンスの平均視聴時間",
"catalog_segment_actions": "カタログセグメントのアクション数",
"catalog_segment_value": "カタログセグメントのアクション合計金額",
"catalog_segment_value_mobile_purchase_roas": "カタログセグメントでの購入のROAS (モバイル)",
"catalog_segment_value_omni_purchase_roas": "カタログセグメントでの購入のROAS (オムニチャネル)",
"catalog_segment_value_website_purchase_roas": "カタログセグメントでの購入のROAS (Webサイト)",
"clicks": "クリック数",
"conversion_values": "コンバージョンの合計価値",
"conversions": "コンバージョン数",
"converted_product_quantity": "購入やアクションによる販売数",
"converted_product_value": "購入やアクションによる販売金額",
"cost_per_15_sec_video_view": "15秒の動画視聴あたりのコスト",
"cost_per_2_sec_continuous_video_view": "連続した2秒の動画視聴あたりのコスト",
"cost_per_action_type": "アクションタイプあたりのコスト",
"cost_per_ad_click": "広告クリックあたりのコスト",
"cost_per_conversion": "コンバージョンあたりのコスト",
"cost_per_dda_countby_convs": "コンバージョンあたりのコスト (DDA)",
"cost_per_inline_link_click": "インラインリンククリックあたりのコスト",
"cost_per_inline_post_engagement": "インライン投稿エンゲージメントあたりのコスト",
"cost_per_one_thousand_ad_impression": "1000回表示された場合のコスト",
"cost_per_outbound_click": "アウトバウンドクリックあたりのコスト",
"cost_per_thruplay": "スループレイあたりのコスト",
"cost_per_unique_action_type": "特定アクションあたりのコスト",
"cost_per_unique_click": "一意のユーザーによるクリックあたりのコスト",
"cost_per_unique_conversion": "一意のコンバージョンあたりのコスト",
"cost_per_unique_inline_link_click": "一意のインラインリンククリックあたりのコスト",
"cost_per_unique_outbound_click": "一意のユーザーによるアウトバウンドクリックあたりの平均コスト",
"cpc": "CPC",
"cpm": "CPM",
"cpp": "CPP",
"created_time": "作成日時",
"ctr": "CTR",
"date_start": "開始日時",
"date_stop": "終了日時",
"dda_countby_convs": "コンバージョン数 (DDA)",
"dda_results": "パフォーマンス結果 (DDA)",
"frequency": "1ユーザーあたりの平均表示数",
"full_view_impressions": "全画面表示数",
"full_view_reach": "完全視聴数",
"impressions": "インプレッション",
"inline_link_click_ctr": "インラインリンククリック率",
"inline_link_clicks": "インラインリンククリック数",
"inline_post_engagement": "インライン投稿エンゲージメント",
"instagram_upcoming_event_reminders_set": "Instagramの今後のイベントリマインダー設定数",
"instant_experience_clicks_to_open": "インスタントエクスペリエンスを開くためのクリック数",
"instant_experience_clicks_to_start": "インスタントエクスペリエンスを開始するためのクリック数",
"instant_experience_outbound_clicks": "インスタントエクスペリエンスでのアウトバウンドクリック数",
"interactive_component_tap": "インタラクティブなコンポーネントのタップ数",
"mobile_app_purchase_roas": "ROAS (モバイル)",
"objective": "広告の目的",
"optimization_goal": "最適化の目標",
"outbound_clicks": "アウトバウンドクリック数",
"outbound_clicks_ctr": "CTR (アウトバウンドクリック)",
"purchase_roas": "ROAS",
"qualifying_question_qualify_answer_rate": "クオリファイイング・クエスチョンの回答割合",
"reach": "リーチ",
"shops_assisted_purchases": "ショップのアシスト購入数",
"social_spend": "ソーシャルメディアに対する単価",
"spend": "単価",
"updated_time": "最終更新日時",
"video_30_sec_watched_actions": "動画 視聴回数 (30秒間)",
"video_avg_time_watched_actions": "動画 平均視聴時間",
"video_continuous_2_sec_watched_actions": "動画 連続した2秒間の視聴回数",
"video_p25_watched_actions": "動画 視聴回数 (25%)",
"video_p50_watched_actions": "動画 視聴回数 (50%)",
"video_p75_watched_actions": "動画 視聴回数 (75%)",
"video_p95_watched_actions": "動画 視聴回数 (95%)",
"video_p100_watched_actions": "動画 視聴回数 (100%)",
"video_play_actions": "動画 広告再生数",
"video_play_curve_actions": "動画 広告アクション追跡",
"video_play_retention_0_to_15s_actions": "動画 視聴維持回数 (0秒〜15秒)",
"video_play_retention_20_to_60s_actions": "動画 視聴維持回数 (20秒〜60秒)",
"video_play_retention_graph_actions": "動画 視聴維持グラフ",
"video_time_watched_actions": "動画 視聴合計時間",
"website_ctr": "CTR (Webサイト)",
"website_purchase_roas": "ROAS (Webサイト)"
}
補足
また、fieldsに指定しても、レスポンスが存在しない場合もあります。上記のいくつかは、エラーにならないものの、値が返ってきませんでした。
まとめ
いかがだったでしょうか。今回は、ネットで調べてもすぐに出てこなかった情報をまとめてみました。
今回のように様々なAPIの使い方の紹介をすることもあれば、Unity, AWS, 量子コンピュータなど幅広いジャンルの紹介を行うこともあります。
お役に立てましたら、いいね, フォローなどよろしくお願いします!