Date range issue while fetching old stats of any campaign - Ads API


#1

Hi, I am having the issue while trying to fetch the historical data

Request Parameters

Array
 (
  [end_time] => 2017-04-03
  [entity] => CAMPAIGN
  [entity_ids] => 7xaoi
  [granularity] => DAY
  [metric_groups] => ENGAGEMENT
  [placement] => ALL_ON_TWITTER
  [start_time] => 2017-03-28
)

API response

stdClass Object
(
[data_type] => stats
[time_series_length] => 6
[data] => Array
(
    [0] => stdClass Object
        (
            [id] => 7xaoi
            [id_data] => Array
                (
                    [0] => stdClass Object
                        (
                            [segment] => 
                            [metrics] => stdClass Object
                                (
                                    [impressions] => Array
                                        (
                                            [0] => 1011
                                            [1] => 0
                                            [2] => 0
                                            [3] => 0
                                            [4] => 0
                                            [5] => 0
                                        )

                                    [tweets_send] => 
                                    [qualified_impressions] => 
                                    [follows] => 
                                    [app_clicks] => 
                                    [retweets] => 
                                    [likes] => 
                                    [engagements] => Array
                                        (
                                            [0] => 17
                                            [1] => 0
                                            [2] => 0
                                            [3] => 0
                                            [4] => 0
                                            [5] => 0
                                        )

                                    [clicks] => Array
                                        (
                                            [0] => 17
                                            [1] => 0
                                            [2] => 0
                                            [3] => 0
                                            [4] => 0
                                            [5] => 0
                                        )

                                    [card_engagements] => 
                                    [replies] => 
                                    [url_clicks] => Array
                                        (
                                            [0] => 6
                                            [1] => 0
                                            [2] => 0
                                            [3] => 0
                                            [4] => 0
                                            [5] => 0
                                        )

                                    [carousel_swipes] => 
                                )

                        )

                )

        )

)

[request] => stdClass Object
(
    [params] => stdClass Object
        (
            [start_time] => 2017-03-27T23:00:00Z
            [segmentation_type] => 
            [entity_ids] => Array
                (
                    [0] => 7xaoi
                )

            [end_time] => 2017-04-02T23:00:00Z
            [country] => 
            [placement] => ALL_ON_TWITTER
            [granularity] => DAY
            [entity] => CAMPAIGN
            [platform] => 
            [metric_groups] => Array
                (
                    [0] => ENGAGEMENT
                )

        )

)

)

Issue are below

1. There dates are mismatch between Request Parameters(Above)  and Request Parameters Returning in API response.

2.There is showing 6 day(time_series_length=6) between date 2017-03-28(YYYY-MM-DD) to 2017-04-03(YYYY-MM-DD). I think, time_series_length should be 7 between date 2017-03-28(YYYY-MM-DD) to 2017-04-03(YYYY-MM-DD).

3. I am sending start time 2017-03-28(YYYY-MM-DD) but the API response it showing 2017-03-27(YYYY-MM-DD)

How the gap is showing between Request Parameters(Which are sending from my side) and Request Parameters Returning in API response?

#2

Hi @deansharedemo,

All your questions are related to the same thing date’s timezone.

In your timezone “2017-03-28” is “2017-03-07T23:00:00Z” in GMT, this is also applicable to end_time.

About the time series length:

Between 2017-03-28 and 2017-04-03 there are 6 complete days, because with that information twitter is going to read:

FROM: 2017-03-28 00:00:00 TO 2017-04-03 00:00:00
IN GMT : 2017-03-27 23:00:00 TO 2017-04-02 23:00:00

Thanks!


#3

Hi @hector_borras, Please review below response
First request is below and requested date params are matching

Start Date=2017-03-21T00:00:00+00:00 && End Date=2017-03-28T00:00:00+01:00

stdClass Object
(
[data_type] => stats
[time_series_length] => 7
[data] => Array
    (
        [0] => stdClass Object
            (
                [id] => 7utab
                [id_data] => Array
                    (
                        [0] => stdClass Object
                            (
                                [segment] => 
                                [metrics] => stdClass Object
                                    (
                                        [impressions] => Array
                                            (
                                                [0] => 0
                                                [1] => 258
                                                [2] => 0
                                                [3] => 0
                                                [4] => 0
                                                [5] => 0
                                                [6] => 0
                                            )

                                        [tweets_send] => 
                                        [billed_charge_local_micro] => Array
                                            (
                                                [0] => 0
                                                [1] => 2000000
                                                [2] => 0
                                                [3] => 0
                                                [4] => 0
                                                [5] => 0
                                                [6] => 0
                                            )

                                        [qualified_impressions] => 
                                        [follows] => 
                                        [app_clicks] => 
                                        [retweets] => 
                                        [likes] => 
                                        [engagements] => Array
                                            (
                                                [0] => 0
                                                [1] => 4
                                                [2] => 0
                                                [3] => 0
                                                [4] => 0
                                                [5] => 0
                                                [6] => 0
                                            )

                                        [clicks] => Array
                                            (
                                                [0] => 0
                                                [1] => 4
                                                [2] => 0
                                                [3] => 0
                                                [4] => 0
                                                [5] => 0
                                                [6] => 0
                                            )

                                        [card_engagements] => 
                                        [replies] => 
                                        [url_clicks] => Array
                                            (
                                                [0] => 0
                                                [1] => 1
                                                [2] => 0
                                                [3] => 0
                                                [4] => 0
                                                [5] => 0
                                                [6] => 0
                                            )

                                        [billed_engagements] => Array
                                            (
                                                [0] => 0
                                                [1] => 1
                                                [2] => 0
                                                [3] => 0
                                                [4] => 0
                                                [5] => 0
                                                [6] => 0
                                            )

                                        [carousel_swipes] => 
                                    )

                            )

                    )

            )

    )
[request] => stdClass Object
    (
        [params] => stdClass Object
            (
                [start_time] => 2017-03-21T00:00:00Z
                [segmentation_type] => 
                [entity_ids] => Array
                    (
                        [0] => 7utab
                    )

                [end_time] => 2017-03-27T23:00:00Z
                [country] => 
                [placement] => ALL_ON_TWITTER
                [granularity] => DAY
                [entity] => CAMPAIGN
                [platform] => 
                [metric_groups] => Array
                    (
                        [0] => ENGAGEMENT
                        [1] => BILLING
                    )

            )

    )

)

In the below second request, date params are mismatching

Start Date=2017-03-28T00:00:00+01:00 && End Date=2017-04-04T00:00:00+01:00

stdClass Object
(
[data_type] => stats
[time_series_length] => 7
[data] => Array
    (
        [0] => stdClass Object
            (
                [id] => 7utab
                [id_data] => Array
                    (
                        [0] => stdClass Object
                            (
                                [segment] => 
                                [metrics] => stdClass Object
                                    (
                                        [impressions] => Array
                                            (
                                                [0] => 28
                                                [1] => 0
                                                [2] => 0
                                                [3] => 0
                                                [4] => 0
                                                [5] => 0
                                                [6] => 0
                                            )

                                        [tweets_send] => 
                                        [billed_charge_local_micro] => Array
                                            (
                                                [0] => 1000000
                                                [1] => 0
                                                [2] => 0
                                                [3] => 0
                                                [4] => 0
                                                [5] => 0
                                                [6] => 0
                                            )

                                        [qualified_impressions] => 
                                        [follows] => 
                                        [app_clicks] => 
                                        [retweets] => 
                                        [likes] => 
                                        [engagements] => Array
                                            (
                                                [0] => 1
                                                [1] => 0
                                                [2] => 0
                                                [3] => 0
                                                [4] => 0
                                                [5] => 0
                                                [6] => 0
                                            )

                                        [clicks] => Array
                                            (
                                                [0] => 1
                                                [1] => 0
                                                [2] => 0
                                                [3] => 0
                                                [4] => 0
                                                [5] => 0
                                                [6] => 0
                                            )

                                        [card_engagements] => 
                                        [replies] => 
                                        [url_clicks] => Array
                                            (
                                                [0] => 1
                                                [1] => 0
                                                [2] => 0
                                                [3] => 0
                                                [4] => 0
                                                [5] => 0
                                                [6] => 0
                                            )

                                        [billed_engagements] => Array
                                            (
                                                [0] => 1
                                                [1] => 0
                                                [2] => 0
                                                [3] => 0
                                                [4] => 0
                                                [5] => 0
                                                [6] => 0
                                            )

                                        [carousel_swipes] => 
                                    )

                            )

                    )

            )

    )

[request] => stdClass Object
    (
        [params] => stdClass Object
            (
                [start_time] => 2017-03-27T23:00:00Z
                [segmentation_type] => 
                [entity_ids] => Array
                    (
                        [0] => 7utab
                    )

                [end_time] => 2017-04-03T23:00:00Z
                [country] => 
                [placement] => ALL_ON_TWITTER
                [granularity] => DAY
                [entity] => CAMPAIGN
                [platform] => 
                [metric_groups] => Array
                    (
                        [0] => ENGAGEMENT
                        [1] => BILLING
                    )

            )

    )
) 

In there first request, you can see that requested date parameters are matching with API response request object. But in second request, the requested date parameters are not matching with API response request object. How it is possible?


#4

@deansharedemo, It’s a subtle change, if you look closely you will see that in the second request both start and end date have +01:00, but not in the first. This is caused by the change between winter and summer time in that region.

Could it be possible?


#5

Hi @deansharedemo,

Did this solved your question?

Thanks!


#6

Hi @hector_borras, Thank you very for your attention. Date range issue has been resolved.