Using segments.date in Select clause returns no data for the customers

423 views
Skip to first unread message

Yaar Or

unread,
Apr 17, 2023, 7:49:36 AM4/17/23
to Google Ads API and AdWords API Forum
This query fails to retrieve data, even though it gets a 200 status_code when executing in Python:

url= 'https://googleads.googleapis.com/v12/customers/XXXXXX/googleAds:search'
params_search= {"query": "SELECT customer.descriptive_name, customer.id, campaign.name, campaign.id, ad_group.name,"
" ad_group.id, metrics.impressions, metrics.clicks, metrics.conversions, "
"metrics.cost_micros, ad_group_ad.ad.id, ad_group_ad.ad.name, segments.date FROM ad_group_ad "
"WHERE segments.date >= '2022-12-25' AND segments.date <= '2023-04-14'",
"page_size": 10000}


Here's the text response to this API request:
'
{
  "fieldMask": "customer.descriptiveName,customer.id,campaign.name,campaign.id,adGroup.name,adGroup.id,metrics.impressions,metrics.clicks,metrics.conversions,metrics.costMicros,adGroupAd.ad.id,adGroupAd.ad.name,segments.date"
}
'

When I removed the segments.date from the Select clause, the API request retrieves data back successfully.

This shows that it is a valid API request in the Query Validator:
Untitled.png


Is there a problem using segments.date in the select clause, or is it possible that there's just no data for the segments.date for these time frames, or something else?

Google Ads API and AdWords API Forum

unread,
Apr 17, 2023, 8:40:24 AM4/17/23
to Google Ads API and AdWords API Forum

Re-posting the last inquiry (https://groups.google.com/g/adwords-api/c/Yfsqi2GGHcofrom the forum as it wasn't routed to our support queue.


Regards,
Google Ads API Team

Google Ads API and AdWords API Forum

unread,
Apr 17, 2023, 9:41:39 AM4/17/23
to Google Ads API and AdWords API Forum
Hi,

Thank you for raising this issue to the Google Ads API support team.

Regarding your concern, you mentioned that you are getting empty results using the above query but when you remove the segments.date from the Select clause, you are able to get data. Having said that, I would suggest referring to our Segmentation and Rules for segments in the WHERE clause guides as this contains more details about this.

Links included in this email:

Regards,
Google Ads API Team
On Monday, April 17, 2023 at 7:49:36 PM UTC+8 yaa...@rivery.io wrote:

Yaar Or

unread,
Apr 18, 2023, 5:04:28 AM4/18/23
to Google Ads API and AdWords API Forum
Hi Google Ads API team!
I am not sure what is the issue, but the docs that were sent are stating that the query is valid, just like the Query Validator screenshot I attached in the first message shows.
Having the segments.date field in the WHERE clause is valid, and when I add the segments.date field to the SELECT clause, the validator shows it is valid too - but executing the API request retrieves no data when including it in the SELECT clause.
I am not sure what the problem is here and would love your assistance in resolving it.
If more information needs to be provided - please let me know what I should add to resolve it.
Message has been deleted

Google Ads API and AdWords API Forum

unread,
Apr 18, 2023, 8:04:14 AM4/18/23
to Google Ads API and AdWords API Forum
Re-posting the last inquiry (https://groups.google.com/g/adwords-api/c/Yfsqi2GGHco) from the forum as it wasn't routed to our support queue.

Regards,
Google Ads API Team

Google Ads API and AdWords API Forum

unread,
Apr 18, 2023, 9:24:54 AM4/18/23
to Google Ads API and AdWords API Forum
Hi,

Thank you for getting back to us. I hope that you are doing well today. 

I understand your concern and as mentioned here in this document, the segments.date, segments.week, segments.month, segments.quarter, and segments.year can be filtered in the WHERE clause without appearing in the SELECT clause. However, to further investigate the issue, could you please provide us the complete request and response logs with request ID and request header generated on your end? You can provide it via Reply privately to the author option. If this option is not available, then send it instead on this email address googleadsa...@google.com. If you haven't enabled the logging yet, logging can be enabled by navigating to the Client libraries > Your client library (ex. Java) > Logging documentation, which you can access from this link.

Kind regards,
Google Ads API
Message has been deleted

Google Ads API Forum Advisor

unread,
Apr 19, 2023, 2:07:25 PM4/19/23
to adwor...@googlegroups.com

Hello Yaar,



Thank you for getting back to us.

I have tried your shared failed query on our end and it appears to be successful. Please find the below query if it matches exactly to your use case, as there may be different values on filters since your shared query has additional characters on it.
 

{
"pageSize": 1000,
"query": "
  SELECT customer.descriptive_name, customer.id, campaign.name, campaign.id, ad_group.name, ad_group.id, metrics.impressions, metrics.clicks, metrics.conversions, metrics.cost_micros, ad_group_ad.ad.id, ad_group_ad.ad.name, segments.date FROM ad_group_ad WHERE segments.date >= '2022-12-25' AND segments.date <= '2023-04-14'
"
}


The above resulted to successfully retrieving data on our end. Let me know how it goes for you.

As a side note, removing your last response on the forum thread as it contains private information.

Regards,

Google Logo Google Ads API Team


ref:_00D1U1174p._5004Q2ko5g6:ref

Yaar Or

unread,
Apr 20, 2023, 3:57:23 AM4/20/23
to Google Ads API and AdWords API Forum
Hi,
the API request attempted with the query you attached was successful but did not provide any data upon my attempt to test it, just like the query I attached in the deleted comment.
Is it possible to go on a call and troubleshoot the issue?
If not - please let us know what the next step can be done to resolve this.
Thank you.

Yaar Or

unread,
Apr 24, 2023, 4:17:44 AM4/24/23
to Google Ads API and AdWords API Forum
Hey team,
Do you have any updates about this?
We are being asked by our client about this and we don't have any answers.
I am looking forward to your response,
Yaar

Google Ads API Forum Advisor

unread,
Apr 24, 2023, 8:10:45 AM4/24/23
to adwor...@googlegroups.com

Hi Yaar,

Thank you for the reply.

Please note that our team may only provide assistance via email. That's why we cannot attend any meeting calls. Moving forward, since we can see results from the query provided while you are not getting data with the same query, could you please provide us with the following information below?

Note that logs can be requested or provided to the developer handling the Google Ads API transactions when logging of the API requests has been enabled. You may check here and click your client library for the specific guideline to enable it.

For REST interface requests, you can enable logging via the curl command by using the -i flag. This will cause the tool to include the HTTP response headers in the output.

You may then send the requested information via the Reply privately to author option. If this option is not available, you may send the details directly to our googleadsa...@google.com alias instead.

Best regards,
Reply all
Reply to author
Forward
0 new messages