Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook, Querying multiple insights metrics with different periods

I can query multiple insights metrics like this:

/insights/page_fans,page_fan_adds,page_impressions_unique

but this returns results for 'page_impressions_unique' with all three periods: day, week, days_28

How can I query multiple metrics while one of them has defined period? I tried something likes this:

/insights/page_fans,page_fan_adds,page_impressions_unique/week

  • but this returns results just for page_impressions_unique/week...
like image 301
El Kopyto Avatar asked May 30 '14 13:05

El Kopyto


1 Answers

The Facebook Insights API will only return values for metrics that satisfy the optional single period given in the call. Since page_fans and page_fan_adds have a period of lifetime, and page_impressions have period day,week,days_28, calling:

/insights/page_fans,page_fan_adds,page_impressions?period=day

Will only result in metrics that are aggregated by day (i.e. page_impressions).

If you want to save on API quota, you may call the API without the period parameter like:

/insights/page_fans,page_fan_adds,page_impressions

and get back lifetime metrics of page_fans,page_fans_adds, and all three periods for page_impressions which you can later parse in your code. The downside to this method is the response is larger and may include information you don't want.

You can also make two API calls instead (one for lifetime metrics, one for day metrics). This option is better when you know you will not hit the API limit.

like image 98
Shayan Masood Avatar answered Sep 21 '22 09:09

Shayan Masood