Google Ads API - hourly breakdown option
I am trying to retrieve a report from google ads api of a metric over time in hourly increments. Is this possible?
You can select a date range and set the dimensions to hourly, for example:
SELECT campaign.name, metrics.impressions, FROM product_group_view WHERE segments.date DURING LAST_30_DAYS AND metrics.impressions > 0
Will get the impressions for 30days, but the data is aggregated across the 30days. Can I retrieve it as a time series?
In facebook, they have me?fields=id,name,insights.fields(impressions).breakdowns(aggregate_by_hourly_audience_timezones).time_increment(1)
This breaks the impressions
data down into hourly increments for each day in the date range (not aggregated - 24 values regardless of date range).
I've searched throught the documentation for a few days now and can't seem to find what I'm looking for.
Edit: So searching through the last 3 days would produce something like the following output (structure of the data not as relevant):
// based on Dorian's example SELECT campaign.name, metrics.clicks, segments.date, segments.hour FROM campaign WHERE segments.date DURING LAST_3_DAYS // OUTPUT {"data": [ "2021-03-08": {0: {clicks: 20}, 1: {clicks: 43}, ...} (out to 23 - 1/ hour) ), "2021-03-09": {0: {clicks: 18}, 1: {clicks: 33}, ...} "2021-03-10": {0: {clicks: 18}, 1: {clicks: 33}, ...} ]}
I'm a bit confused by your example, because you mention adding the hourly dimension but it's not actually present in your query.
In any case, not all reports in the Ads API support all segments. In your report above, when querying the product_group_view resource you cannot add segments.hour—segments.date however is possible. The documentation lists which segment fields are available for which resources.
For an example on how to get hourly data in a report where that's possible (campaign):
SELECT campaign.name, metrics.clicks, segments.date, segments.hour FROM campaign WHERE segments.date DURING LAST_30_DAYSThis will return a single row for each combination of date, hour and campaign where at least one click was recorded during the last 30 days.
Thanks for the respone @dorian. I'm having some authentication issues with google at the moment so I can't actually test this, but can you confirm the output would be something similar to my edit?
The specific format of the output will depend on whether you use the gRPC interface or the REST one. In either case, you won't get data nested by segments like in your edit, but rather a flat table of GoogleAdsRows.