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
2
Answers
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.
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
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.