How to specify date range with geographic_view & segments.geo_target_city?

238 views
Skip to first unread message

Nam Nguyen

unread,
Mar 28, 2019, 5:09:40 PM3/28/19
to AdWords API and Google Ads API Forum

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.


Below is the log
-------
Method: /google.ads.googleads.v1.services.GoogleAdsService/Search
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 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'"
    }
  ]
}

googleadsapi...@google.com

unread,
Mar 28, 2019, 11:45:33 PM3/28/19
to AdWords API and Google Ads API Forum
Hi,

Thank you for giving us a detailed explanation of the issue. Unfortunately, segments.geo_target_city and segments.date are not selectable with each other in Google Ads API. You may refer to this link to see the fields that are selectable with segments.geo_target_city.

Let me know if you have any further concerns.

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/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@googlegroups.com
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 adwords-api+unsubscribe@googlegroups.com.
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/094cd6d4-a7c5-432f-a5a2-301b7f0a6817%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nam Nguyen

unread,
Mar 29, 2019, 1:50:24 AM3/29/19
to AdWords API and Google Ads API Forum
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.

googleadsapi...@google.com

unread,
Mar 29, 2019, 4:27:24 AM3/29/19
to AdWords API and Google Ads API Forum
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/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@googlegroups.com
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 adwords-api+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.

Nam Nguyen

unread,
Mar 29, 2019, 5:08:04 AM3/29/19
to AdWords API and Google Ads API Forum
Hi Dave,

Thanks for your reply.

Is this a limitation of Google Ads API that should be considered? Because I can do this with the following report definition in AdWords API:
{
    'reportName': 'Custom Report',
    'dateRangeType': 'TODAY',
    'reportType': 'GEO_PERFORMANCE_REPORT',
    'downloadFormat': 'CSV',
    'selector': {
'fields': ['CampaignName', 'Impressions', 'Clicks', 'CountryCriteriaId', 'CityCriteriaId']
    }
}
which returns impressions and clicks segmented by city, filtered by today date range.

If this API limitation can't be overcome in current version, is there any other way to apply date filter to geographic_view with segments.geo_target_city?

On Friday, March 29, 2019 at 4:09:40 AM UTC+7, Nam Nguyen wrote:

googleadsapi...@google.com

unread,
Mar 29, 2019, 5:55:21 AM3/29/19
to AdWords API and Google Ads API Forum
Hi Nam,

Unfortunately, currently there is no workaround for this. For now, I will let the team know about your concern by filing a feature request. Take note that there will be no guarantee that this would be implemented. To get the latest updates, I would suggest you follow our blog post.


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/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@googlegroups.com
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 adwords-api+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.

googleadsapi...@google.com

unread,
Apr 22, 2019, 3:35:03 AM4/22/19
to AdWords API and Google Ads API Forum
Hi Nam,

I would like to inform you that a fix has been included in production to filter segments.geo_target_city using segments.date. You could now try executing your previous query and it should work as intended. Should you encounter the error again, let me know so I could assist you further.


Regards,
Dave Paurillo
Google Ads API Team


=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

--
Reply all
Reply to author
Forward
0 new messages