Paul Razvan Berg
Paul Razvan Berg

Reputation: 21400

Facebook Marketing API how to retrieve Ads Action Stats

I've been fighting with the Facebook Marketing API in the last days. I simply want to retrieve the cost_per_action_type but matched with the campaign's objective.

I've discovered this: https://developers.facebook.com/docs/marketing-api/reference/ads-action-stats/.

But I simply cannot retrieve that data! I didn't find any working examples or at least guides on the web. I pasted some links below but they aren't of any help. Maybe this is how connected to the insights API, but I don't know how.

Do you have any idea?

Related: Match facebook campaign objective with insights actions types https://github.com/facebook/facebook-php-ads-sdk/issues/278

Upvotes: 5

Views: 3562

Answers (2)

metatrons
metatrons

Reputation: 33

I faced the same problem like you, I use almost one day to figure it out. The point is you cannot reach the Ads Action Stats, the reason why is that the just mean status of the ads-insight; therefore,you would just see

 website_ctr [{'action_type': 'link_click', 'value': '0.714286'}]
cost_per_action_type [{'action_type': 'link_click', 'value': '30'}, {'action_type': 'landing_page_view', 'value': '30'}, {'action_type': 'post_engagement', 'value': '30'}, {'action_type': 'page_engagement', 'value': '30'}, {'action_type': 'omni_view_content', 'value': '15'}]
cpc 7.5
cpm 214.285714
spend 60
date_start 2019-06-03
date_stop 2019-07-03
age 35-44

you can find that [{'action_type': 'link_click', 'value': '30'}, {'action_type': 'landing_page_view', 'value': '30'}, {'action_type': 'post_engagement', 'value': '30'}, {'action_type': 'page_engagement', 'value': '30'}, {'action_type': 'omni_view_content', 'value': '15'}] is the Ads Action Stats you want.

Upvotes: 1

Jeff S.
Jeff S.

Reputation: 81

The way to get the cost per action type is with this endpoint:
<campaign ID>/insights?fields=cost_per_action_type

You can substitute Campaign ID with Adset ID if you prefer.

Upvotes: 2

Related Questions