Data query filtered at a different level than the FROM clause in the Google Ads API

120 views
Skip to first unread message

José Matias

unread,
Mar 13, 2025, 8:43:14 AM3/13/25
to Google Ads API and AdWords API Forum

We know that to make a query in Google Ads, we need the FROM clause, and the filters will be applied from it, as shown in the example below:

{
  "query": "SELECT customer.descriptive_name, metrics.impressions, metrics.clicks, metrics.ctr, segments.date
           FROM campaign
           WHERE segments.date >= '2025-03-01'
             AND segments.date <= '2025-03-11'
             AND campaign.name LIKE '%WHATEVER%'
             PARAMETERS omit_unselected_resource_names=true",
  "summaryRowSetting": "SUMMARY_ROW_WITH_RESULTS"
}

However, a common demand when generating reports is to produce data filtered by campaign, for example, but segmented by date at the account level.

In Looker Studio, this capability is apparent, where we can use a campaign filter in a table widget that will generate aggregated data by date.

As far as I know, Looker only makes one query per widget to the Google Ads API (we know that Looker's summary line is a separate query), but how is it possible in Looker and other tools to aggregate data at a different level from the FROM clause?
Captura de Tela 2025-03-13 às 09.31.55.png

In the forum, the recommendations were to make multiple queries using the summary row, such as a query per day with the summary row and ignoring the values that come in N lines for the N campaigns in the account, but this method seems quite inefficient.

How is it possible to work efficiently with queries filteredat different levels?

Google Ads API Forum Advisor

unread,
Mar 13, 2025, 12:23:32 PM3/13/25
to jmati...@gmail.com, adwor...@googlegroups.com
Hi Jose,

Thank you for reaching out to the Google Ads API support team.​ ​​

Based on the information provided, it appears that your issue is related to Looker Studio. I suggest reaching out to the Looker studio support team as they should be better equipped to address your concern. 

Please note that our team can only assist with the technical queries or concerns related to the Google Ads API.

Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5
[2025-03-13 16:22:29Z GMT] This message is in relation to case "ref:!00D1U01174p.!5004Q02vH9Of:ref" (ADR-00294017)



José Matias

unread,
Mar 13, 2025, 5:22:11 PM3/13/25
to Google Ads API and AdWords API Forum

Thank you for your response, but it's not related to Looker Studio; I used it just as an example.

My question is how to filter and aggregate data when we have a filter in a different clause from the FROM in the Google Ads API.

Google Ads API Forum Advisor

unread,
Mar 14, 2025, 12:08:35 AM3/14/25
to jmati...@gmail.com, adwor...@googlegroups.com
Hi,

Could you clarify how you intend to filter the data at a different level than the FROM clause in the Google Ads API? Different levels mean on what level you are trying to filter the data? Can you provide a specific example with the filters that you wish to apply on those? In your initial email, you mentioned filtering data segmented at the account level. Filtering at the account level indicates without applying any filters like date segments in the 'WHERE' clause. If you wish to apply date segments to filter the data then you need to apply the same date range in the Google Ads UI when comparing the API results with the UI. I would recommend you to refer to the Query Structure documentation to understand how to apply filters when retrieving data through the Google Ads API. Additionally, you can use the Google Ads Query Builder and Query Validator to construct and validate your queries effectively.

 

Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5

[2025-03-14 04:08:02Z GMT] This message is in relation to case "ref:!00D1U01174p.!5004Q02vH9Of:ref" (ADR-00294017)



Message has been deleted

Google Ads API Forum Advisor

unread,
Mar 14, 2025, 5:29:46 PM3/14/25
to jmati...@gmail.com, adwor...@googlegroups.com
Hi,

In order to assist you further, please note that the provided screenshots are from Looker Studio, which is outside the scope of Google Ads API support. Could you confirm if you can retrieve the data with the same date and campaign name segmentation directly from the Google Ads UI? If yes, I would request you to provide an uncropped UI screenshot of the Google Ads account (with visible customer ID) by highlighting the fields and metrics for which you want to fetch the data from the Google Ads API. 
 

Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5

[2025-03-14 21:29:04Z GMT] This message is in relation to case "ref:!00D1U01174p.!5004Q02vH9Of:ref" (ADR-00294017)



Message has been deleted

Google Ads API Forum Advisor

unread,
Mar 16, 2025, 9:42:02 PM3/16/25
to jmati...@gmail.com, adwor...@googlegroups.com
Hi, 

Please be informed that I have removed your response from the forums as it contains the PII information.

It is not possible to retrieve data from those two campaigns in an aggregated, grouped, or summed format by day, as shown in the Looker report you shared. When using the campaign report, we apply filters on both the date and campaign name in the 'WHERE' clause. As a result, the data is retrieved separately for each campaign and segmented by date. Therefore, you cannot obtain a report that combines both campaigns' data while keeping it segmented by date. However, we were able to retrieve the data as per your screenshot from the Google Ads API using the campaign resource which will retrieve the results separately for each campaign. However, I am sharing with you the sample GAQL query:

SELECT campaign.name, metrics.impressions, metrics.ctr, segments.date, 
campaign.resource_name FROM campaign WHERE campaign.name LIKE '%DESTINO%' AND 
segments.date BETWEEN '2025-03-01' AND '2025-03-11'

Note that this query will fetch both the campaigns data individually which are segmented by date. 


Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5

[2025-03-17 01:41:26Z GMT] This message is in relation to case "ref:!00D1U01174p.!5004Q02vH9Of:ref" (ADR-00294017)



José Matias

unread,
Mar 17, 2025, 6:03:35 AM3/17/25
to Google Ads API and AdWords API Forum

Thank you for the response.

This query is the same one I previously indicated.

I would like to understand how the Google Ads UI manages to aggregate the data from these two campaigns by day?

Captura de Tela 2025-03-17 às 06.53.25.png

Google Ads API Forum Advisor

unread,
Mar 17, 2025, 8:55:59 AM3/17/25
to jmati...@gmail.com, adwor...@googlegroups.com

Hi,

Kindly note that the concerns related to the Google Ads UI are out of scope for the Google Ads API support team as our team can only assist with the technical queries or concerns related to the Google Ads API. I'm adding another support team for their expertise in troubleshooting your issue. You should receive an email to assist you shortly.


Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5

[2025-03-17 12:55:20Z GMT] This message is in relation to case "ref:!00D1U01174p.!5004Q02vH9Of:ref" (ADR-00294017)



José Matias

unread,
Mar 17, 2025, 9:22:43 AM3/17/25
to Google Ads API and AdWords API Forum

I mentioned the Google Ads UI because you requested it.

Are you saying then that there is absolutely no alternative in the API to bring the data grouped in the format I indicated?

Would the only alternative be to perform day-by-day queries with summary rows to get the aggregated data with the proposed filter?

Google Ads API Forum Advisor

unread,
Mar 17, 2025, 12:10:14 PM3/17/25
to jmati...@gmail.com, adwor...@googlegroups.com
Hi,

Unfortunately, the requested data grouping, which involves combining metrics from multiple campaigns by date, is not feasible. Metrics are available for individual campaigns, but cross-campaign aggregation by date is not possible through Google Ads Api.
 

Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5

[2025-03-17 16:09:25Z GMT] This message is in relation to case "ref:!00D1U01174p.!5004Q02vH9Of:ref" (ADR-00294017)



José Matias

unread,
Mar 17, 2025, 12:55:06 PM3/17/25
to Google Ads API and AdWords API Forum

So the only way would be to make a query day by day with the summary row enabled, then I would have the aggregated data for that date/day for 2 campaigns, correct?

Google Ads API Forum Advisor

unread,
Mar 17, 2025, 3:37:41 PM3/17/25
to jmati...@gmail.com, adwor...@googlegroups.com
Hi,

Yes, the data should be aggregated because it is not possible to use the API to combine metrics from multiple campaigns by date.

Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5

[2025-03-17 19:36:54Z GMT] This message is in relation to case "ref:!00D1U01174p.!5004Q02vH9Of:ref" (ADR-00294017)



José Matias

unread,
Mar 17, 2025, 3:47:34 PM3/17/25
to Google Ads API and AdWords API Forum
So in the case of a query for a period of 4 days, you would have to make 4 separated queries, one for each day with the summary row enabled, right?

Google Ads API and AdWords API Forum

unread,
Mar 18, 2025, 8:42:40 AM3/18/25
to Google Ads API and AdWords API Forum

Hi,


Yes, your understanding is correct.


Thanks,

Google Ads API Team

José Matias

unread,
Mar 19, 2025, 7:01:52 AM3/19/25
to Google Ads API and AdWords API Forum

From another ticket you answered:

"Additionally, please note that whatever features are present in the Google Ads UI, only those features are possible via the Google Ads API. If you're trying to retrieve a specific feature via the API, please provide a screenshot of the corresponding feature in the Google Ads UI so we can guide you on how to fetch it via the API."

If it's possible in the interface, why isn't it possible in the API?

Google Ads API Forum Advisor

unread,
Mar 19, 2025, 11:59:00 AM3/19/25
to jmati...@gmail.com, adwor...@googlegroups.com

Hi,

Could you please confirm whether you are able to combine metrics from multiple campaigns by date in the Google Ads UI? If yes, kindly provide us with the uncropped UI screenshot of the metrics that you are combined along with the date for further investigation.

You can send the details via Reply privately to the author option, or direct private reply to this email


Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5

[2025-03-19 15:58:23Z GMT] This message is in relation to case "ref:!00D1U01174p.!5004Q02vH9Of:ref" (ADR-00294017)



Reply all
Reply to author
Forward
0 new messages