I am trying to get post insights for a page feed using Facebook Graph API version 2.7 ..
If I only write:
'[Page ID]/feed?fields=insights'
It asks for metric, which indicates it should work... But when specifying a metric:
'[Page ID]/feed?fields=insights/post_impressions/lifetime'
I get syntax error.
I've tried with . notation as:
'[Page ID]/feed.insights/post_impressions/lifetime'
But stil no luck!
I know I can do it post by post (separate calls to API), but that is what I'm trying to avoid.
Anyone know what the correct syntax is for nested insights?
This bug report was able to shed some light: https://developers.facebook.com/bugs/1755454881375647/
You can use the metric
keyword to specify the metrics you want, like so:
/page-id/posts?fields=insights.metric(post_impressions,post_consumptions_unique)
Name the metrics you are interested in there, and separate them with a comma.
Specifying the period (where applicable) seems to work by the same kind of syntax,
/…?fields=insights.metric(…).period(lifetime)
(Although it might not work to request different periods for different metrics in one go.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With