How can I retrieve data from the SEARCH_QUERY_PERFORMANCE_REPORT for only a specific hour?

49 views
Skip to first unread message

Aleksy Zajac

unread,
Jun 10, 2025, 5:11:39 AM6/10/25
to Google Ads Scripts Forum
Hi,

I'd like to restrict a SEARCH_QUERY_PERFORMANCE_REPORT to a specific day and hour. How can I achieve this?

I couldn't find a time or hour field in the documentation.

I tried to use the query:
var report_query = "SELECT CampaignName, AdGroupName, Query, Impressions, Clicks, Cost FROM SEARCH_QUERY_PERFORMANCE_REPORT WHERE Date ='2025-06-09' and Segments.Hour = 20";
var report = AdsApp.report(report_query);

but it's not working.

Thanks a lot,
Aleksy

Rahul Kumar

unread,
Jun 10, 2025, 6:01:44 PM6/10/25
to Google Ads Scripts Forum
Hi Aleskey,

Try  HourOfDay instead of Segments.Hour

Thanks,

Google Ads Scripts Forum Advisor

unread,
Jun 10, 2025, 7:37:55 PM6/10/25
to adwords...@googlegroups.com

Hi Aleksy,

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

@Rahul - Thanks for suggesting a solution to the user.

I would like to inform you that the “segments.hour” field will retrieve segments based on the input hour and it is the correct format (you have used Segments.Hour in this case). Kindly replace “Segments.Hour” with “segments.hour”. Also, it seems that you are using invalid resource “SEARCH_QUERY_PERFORMANCE_REPORT”. I would recommend that you use the “ad_group” resource and build the query again by using the available metrics in the resource.

Additionally, you can utilize the Google Ads Query Builder and Query Validator to build and validate the queries before retrieving the data from the Google Ads API.

I hope this helps! Feel free to get back to us with the below details if the issue still persists.

  • Google Ads account ID/CID
  • Name of the affected script
  • Screenshot of the issue
  • Shareable spreadsheet link if you are using any in the script. You may refer to this article to share a file publicly
You can share the requested details via Reply privately to the author option or a direct private reply to this email.

Thanks,
 
Google Logo Google Ads Scripts Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5
[2025-06-10 23:37:26Z GMT] This message is in relation to case "ref:!00D1U01174p.!500Ht01reuNi:ref" (ADR-00313672)



Reply all
Reply to author
Forward
0 new messages