created_date in DAY level data from twitter Ads

analytics
best-practices

#1

Hi,

Below is the code that i’m using to pull DAY level metrics from my twitter Ad account.

resource = '/0/stats/accounts/{account_id}/campaigns/{id}'.format(account_id=account.id,id=id2)
params = {'start_time':'2015-09-01T07:00:00Z','granularity':'HOUR','metrics':'promoted_video_total_views,promoted_tweet_profile_impressions,promoted_tweet_search_impressions,promoted_tweet_timeline_impressions,promoted_tweet_search_engagements,promoted_tweet_profile_engagements,promoted_tweet_timeline_engagements,promoted_account_follows,billed_charge_local_micro,billed_engagements,billed_follows,promoted_tweet_search_url_clicks,promoted_tweet_timeline_url_clicks,promoted_tweet_profile_url_clicks,promoted_tweet_search_clicks,promoted_tweet_timeline_clicks,promoted_tweet_profile_clicks'}
response = Request(client, 'get', resource, params=params).perform()

Client is defined before hand. The problem here is that the time( which date on which each metric is recorded. Same as the one from the Twitter Ads Campaign dashboard export) is missing from the API output.

Any help on this is much appreciated.


#2

Hi @TheNightBefore! First of all, I see that your request is with granularity HOUR, and not DAY as the title of the thread states. It would be nice for you to correct the wrong one.

Are you saying that the start_time and end_time are not present in the data returned?

P.S.: that’s a very long time to request analytics data for… almost 6 months. I’m surprised you don’t get an error with this call, for requesting too much data.


#3

Hi @majoritasdev

I’ve corrected the granularity to DAY and I have also defined the start_time and end_time now. But the problem here is not with the start_time and end_time.

The above is the snapshot of the output I’m getting. My question here is how do we retrieve the timestamp for each entry.
For eg. for what date is the second row tagged to is my question.

Yes, I read that It’s best to pull only 7- day data in one request but we are uploading this data to our DB. So, we need the historic data as well.

Thanks for the help!


#4

Data is returned for each metric in a time series based on your request of either HOUR (recommended), DAY or TOTAL granularity.

( https://dev.twitter.com/ads/analytics )

If you request daily stats for, say, promoted_tweet_timeline_impressions, between 2015-09-01 and 2015-09-05, and you get, say,

promoted_tweet_timeline_impressions: [
    0,
    5,
    10,
    2,
    9
]

…then the n-th number of impressions corresponds to the n-th day in the interval between the start_time and end_time supplied. So:

promoted_tweet_timeline_impressions: [
    0, // is for 2015-09-01
    5, // is for 2015-09-02
    10, // is for 2015-09-03
    2, // is for 2015-09-04
    9 // is for 2015-09-05
]

#5

Thanks @majoritasdev for the quick reply.
This is what I was looking for :slight_smile:


#6

:slightly_smiling:

Just a note, @TheNightBefore: if it’s solved, it’s a good practice to mark the post with the answer as being the solution, so others know this thread has been solved already. Thank you! :slightly_smiling: