Hi Nam,
Apologies for the confusion. I'm afraid that Google Ads API will consider
all fields inside the query(including WHERE clause) as selectable fields.
This said, you could not use segments.date to filter the
segments.geo_target_city as segments.date is not included in the selectable
fields of segments.geo_target_city.
Should you have any further clarifications, feel free to write back.
Regards,
Dave Paurillo
Google Ads API Team
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
On 03/29/19 13:50:24 [email protected] wrote:
Hi,
Thanks for your reply. Perhaps my explanation wasn't clear enough.
I'm looking for a way to filter segments.geo_target_city by date, not
combining segments.geo_target_city and segments.date.
As far as I know, if I add "WHERE segments.date DURING TODAY" to the query,
Google Ads API considers it as another segments and then combines it with
segments.geo_target_city.
On Friday, March 29, 2019 at 4:09:40 AM UTC+7, Nam Nguyen wrote:
Hi,
(I'm using Google Ads API v1)
I've read that segments.geo_target_city can't be selected with
segments.date (https://developers.google.com/google-ads/api/docs/
fields/segments#segmentsgeo_target_city)
However, using segments.date seems to be the only way to specify date range
in Google Ads API (https://developers.google.com/google-ads/api/docs/query/
date-ranges)
If I run the query without segments.date, it returns all my campaigns.
I can add segments.week but that's not what I need.
In AdWords API, this can be achieved (https://developers.google.
com/adwords/api/docs/appendix/reports/geo-performance-report#date)
Below is the log
-------
Method: /google.ads.googleads.v1.services.GoogleAdsService/Search
Host: googleads.googleapis.com:443
Headers: {
"developer-token": "REDACTED",
"login-customer-id": "*********",
"x-goog-api-client": "gl-python/3.6.8 grpc/1.18.0 gax/1.7.0 gapic/1.1.1"
}
Request: {
"customerId": "**********",
"query": "SELECT metrics.clicks, metrics.impressions,
segments.geo_target_city FROM geographic_view WHERE metrics.impressions > 0
AND segments.date DURING TODAY LIMIT 100",
"pageSize": 1000
}
Response
-------
Headers: {
"google.ads.googleads.v1.errors.googleadsfailure-bin":
"\np\n\u0002(\u001f\u0012jThe following pairs of fields may not be selected
together: 'segments.geo_target_city' and 'segments.date'",
"grpc-status-details-bin": "\b\u0003\u0012%Request contains an invalid
argument.\u001a\u0001\nCtype.googleapis.com/google.ads.googleads.v1.errors.
GoogleAdsFailure\u0012r\np\n\u0002(\u001f\u0012jThe
<http://nCtype.googleapis.com/google.ads.googleads.v1.errors.GoogleAdsFailure%5Cu0012r%5Cnp%5Cn%5Cu0002(%5Cu001f%5Cu0012jThe>
following pairs of fields may not be selected together:
'segments.geo_target_city' and 'segments.date'",
"request-id": "RSGT-rPdBugjlbJPK0sYFg"
}
Fault: {
"errors": [
{
"errorCode": {
"queryError": "PROHIBITED_FIELD_COMBINATION_IN_SELECT_CLAUSE"
},
"message": "The following pairs of fields may not be selected
together: 'segments.geo_target_city' and 'segments.date'"
}
]
}
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/6938a3bd-01bf-4a2a-aa51-9267de0973c0%40googlegroups.com
<https://groups.google.com/d/msgid/adwords-api/6938a3bd-01bf-4a2a-aa51-9267de0973c0%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/4g2ogtphn000000003pk6q001jiig6x68mj8d9m60o30c1g68qjec9n%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.