Can't understand values being returned by Facebook Insights API

1.4k Views Asked by At

I don't understand the way the API returns values. Here's a sample of a page_impressions call, with 'week' as the period.

"values"=>
[{"end_time"=>"2012-01-08T08:00:00+0000", "value"=>1116},
{"end_time"=>"2012-01-09T08:00:00+0000", "value"=>1171}, 
{"end_time"=>"2012-01-10T08:00:00+0000", "value"=>1175}]

It seems that they're showing how many hits I had in the last 7 days up to the date in "end_time", is that correct? If it is, then I don't understand what use this would have, there is a huge overlap in the data.

How can I get the number of impressions of the last weeks instead? And how can I get more than 3 values to display? I really can't understand the logic behind this or how it could be useful.

1

There are 1 best solutions below

1
On

What's happening here is that you're being given the total number of page_impressions for the 7-day period ending on each of the dates shown (i.e., how many times was the page seen over the past 7 days assuming the week ended on the end_time? and then on end_time+1? end_time+2)

Facebook is returning three (3) separate readings, presumably so you can spot/review very local trends (e.g., "are my weekly impressions creeping up?) or perhaps because you missed a measurement and want to have values for every day.

To answer your question specifically:

  • The 7-day period 2012-01-01 through 2012-01-08 12:00am* had 1,116 impressions.
  • The 7-day period 2012-01-02 through 2012-01-09 12:00am* had 1,171 impressions.
  • The 7-day period 2012-01-03 through 2012-01-10 12:00am* had 1,175 impressions.

    • As is quoted below, the end_time itself is always midnight in PDT. Thus, an end_time of 2012-01-08 really means the measurement stopped the night before, i.e., at 1 minute past 11:59pm on 2012-01-07.

From https://developers.facebook.com/docs/reference/fql/insights/:

The end of the period during which the metrics were collected, expressed as a UNIX time (which should always be midnight, Pacific Daylight Time) or using the function end_time_date() which takes a date string in 'YYYY-MM-DD' format. Note: If the UNIX time provided is not midnight, Pacific Daylight Time, your query may return an empty resultset. Example: To obtain data for the 24-hour period starting on September 15th at 00:00 (i.e. 12:00 midnight) and ending on September 16th at 00:00 (i.e. 12:00 midnight), specify 1284620400 as the end_time and 86400 as the period. Note: end_time should not be specified when querying lifetime metrics.