4

I’m attempting to query Ad Group stats API for an Account for a full day’s worth of data.

The Facebook documentation recommendation is to specify start and end dates along with times (in UTC) as relates to the ad_account time zone, as in the following examples:

1) Pacific Time (12/8/2012):

/adgroupstats?start_time=2012-12-08T08:00:00&end_time=2012-12-09T08:00:00&
stats_mode=with_delivery&include_deleted=true&access_token=

2) Daylight savings (8/8/2012):

/adgroupstats?start_time=2012-08-08T07:00:00&end_time=2012-08-09T07:00:00
&stats_mode=with_delivery&include_deleted=true&access_token=

I'm looking for a better way to account for daylight savings time, so I'd like to know if excluding the time entirely is an option, since I'm just after the full day.

In testing, I've found the following to return the same results as option 2, but I'm wondering if this is a reliable method, since it is undocumented:

/adgroupstats?start_time=2012-08-08T00:00:00&end_time=2012-08-09T00:00:00&
stats_mode=with_delivery&include_deleted=true&access_token=
Jason13
  • 86
  • 7
  • Please note: I have read the documentation (thats why I included the link), The issue is when I query on behalf of a customer and have the timezone off by an hour (due to daylight savings time). FB will adjust the query to include the following day so you could end up with two days worth of stats. I've noticed that by leaving off the time portion of the date FB figures I want one day worth of data as relates to that clients timezone and gives me 100% correct data in return. I'm asking this question since this isn't reflected in the documentation - does anyone have any additional insite? – Jason13 Feb 20 '13 at 22:41

2 Answers2

1

You MUST provide start and end time. Otherwise there wouldn't be any way to know which day's stats that you want.

Refer to the "Querying Unique Stats" of the Stats Documentation.

And I quote "Note: As times are expressed in UTC you must manually adjust for daylight savings time in your request"

Hence the solution should be how to program your request to have DST adjusted start/end times.

If you're using PHP, refer to this: How can I detect day light savings automatically in PHP?

or: PHP daylight saving time detection

Community
  • 1
  • 1
  • I have read the documentation, the client is not generating the query, I am. The issue is when you query on behalf of a customer and you have the timezone off by an hour (due to daylight savings time). FB will adjust the query to include the following day so you could end up with two days worth of stats. I've noticed that by leaving off the time portion of the date FB figures I want one day worth of data as relates to that clients timezone and gives me 100% correct data in return. I'm asking this question since this isn't reflected in the documentation. -thanks – Jason13 Feb 20 '13 at 15:18
1

So to answer my own question - leaving off the timestamp portion is no longer working after the latest FB API update...

As a work around for the daylight savings time issue - in my code I call out to the /stats api for a single day (making start and end dates the same and leaving off the time portion):

/stats?start_time=2012-08-01T00:00:00&end_time=2012-08-01T00:00:00

I retrieve the results of this call and look at the times Facebook returned to determine if FB adjusted this query for the Clients daylight savings time.

FB return: "start_time": "2012-07-31T07:00:00+0000",

Then I can query the /adgroupstats api with the correct times:

/adgroupstats?start_time=2012-08-01T07:00:00&end_time=2012-08-02T07:00:00

Note: /adgroupstats api does not seem to return the FB adjusted start time so I used /stats api as a work around

Jason13
  • 86
  • 7