Need help using Query API for python to display age_range and gender_type

98 views
Skip to first unread message

Vinutha Nayak

unread,
Jul 3, 2019, 6:01:58 AM7/3/19
to AdWords API and Google Ads API Forum
Hi ,

I am trying to generate a report capturing gender, age  For some reason all are being displayed as 0. 

I am using google ads API and trying the same in python. Can anyone quickly point out what is going wrong ?


Following is the query :

query2 = (
' SELECT campaign.name, campaign.id, campaign.start_date, campaign.end_date,  '
' campaign_criterion.gender.type,campaign_criterion.age_range.type, campaign_criterion.proximity.radius '
' FROM campaign_criterion '
' LIMIT 100')

printing it as follows :
print(
' Campaign name : "%s" , Campaign id : "%s" , Campaign start date : "%s" , Campaign end date : "%s" '
' Gender_type : "%s" , Age_range_type : "%s" , Radius : "%s" '
% (campaign.name.value, campaign.id.value, campaign.start_date.value, campaign.end_date.value,
campcrit.gender.type, campcrit.age_range.type, campcrit.proximity.radius.value))


I think since they are ones with a set of response values as in age ranges and Gendertypes, they need to be handled differently while reading the response. 

Can anyone quickly point out the mistake and correct me please ?

Thanks and Regards,
Vinutha Nayak

Google Ads API Forum Advisor Prod

unread,
Jul 4, 2019, 6:20:49 AM7/4/19
to nayakv...@gmail.com, adwor...@googlegroups.com

Hi Vinutha,

Thank you for reaching out to us.

I was able to replicate your query on my end, and can confirm that I was indeed getting 0's for both the gender and the age range values. It may happen that you have not specified any gender or age range targeting in your campaigns; thus, the gender field correctly outputs 0 (or UNSPECIFIED), while the age range field correctly outputs 0 as well (or UNSPECIFIED as well).

That said, those fields outputting ints instead of String variables (like "UNSPECIFIED") is working as intended at the moment; you may wish to join the related GitHub issue discussion here if you feel that this will be an issue on your end.

Regards,
Ziv
Google Ads API Team



ref:_00D1U1174p._5001UCanIe:ref

Vinutha Nayak

unread,
Jul 4, 2019, 7:07:42 AM7/4/19
to AdWords API and Google Ads API Forum
Hi Ziv,

Thanks for responding back. 

I have ensured that both gender_type and age_range are enabled ( in green) in UI. But the output still comes as 0.

What I wondering is, considering it returns a set of values and not single value, is my syntax correct ?

Could you please help me here ? I am really stuck on this one.

Thanks and Regards,
Vinutha Nayak

Google Ads API Forum Advisor Prod

unread,
Jul 7, 2019, 11:03:28 PM7/7/19
to nayakv...@gmail.com, adwor...@googlegroups.com

Hi Vinutha,

Thank you for providing additional details on your concern.

Could you confirm if my following assumption is correct: you may be trying to edit the age range and gender criteria via the Demographics screen for a campaign in the Google Ads UI (see AgeRange_AdGroup and Gender_AdGroup screenshots). If it is, then do be noted that editing the criteria in those screens will only include (or exclude) the said criteria on an ad group level.

For age range and gender inclusions or exclusions on the campaign level, you may want to click on More -> Exclusions instead from the same Demographics screen (see Exclusions_Campaign screenshots). Adding exclusions here will reflect at the campaign level, and will properly reflect on the Google Ads API side as well (that is, it will reflect on the query you are using for this case).

Alternatively, if you wish to change the age range and gender criteria for ad groups instead of campaigns, then you may keep using the same UI as found in the AgeRange_AdGroup and Gender_AdGroup screenshots, and edit your query instead so that it uses the ad_group and ad_group_criterion resources, with the age range and gender criteria fields being ad_group_criterion.age_range.type and ad_group_criterion.gender.type, respectively.

Let me know if this works for you.

Regards,
Ziv,
Google Ads API Team



ref:_00D1U1174p._5001UCanIe:ref
Exclusions_Campaign.png
AgeRange_AdGroup.png
Gender_AdGroup.png

Vinutha Nayak

unread,
Jul 8, 2019, 10:18:59 AM7/8/19
to AdWords API and Google Ads API Forum
Hi Ziv,

Thanks for the detailed explanation.

Yes , you were right in the sense that I was trying to edit the age and gender criteria via the Demographics screen which is for Adgroup campaign and in code as pasted above, I was trying to fetch them at campaign level. 

I corrected myself, but then arises I have these two questions. 

1. As far as I understand, by default ( i,e if we don't explicitly specify something in campaign_criterion) then by default all gender types  and age range should be included. So even in that case, shouldn't the result be something different   than "0" that I am seeing now .  ?  Please correct me if I am wrong here. 


2.  Given that I was earlier trying to modify age  range and gender type values at AdCampaign level in the UI , I tried one more thing , I specifically set the values at campaign_criterion at code level as follows:
   campaign_criterion.age_range.type = client.get_type('AgeRangeTypeEnum', version='v1').AGE_RANGE_18_24
campaign_criterion.age_range.type = client.get_type('AgeRangeTypeEnum').AGE_RANGE_25_34
campaign_criterion.gender.type = client.get_type('GenderTypeEnum').MALE
campaign_criterion.gender.type = client.get_type('GenderTypeEnum').FEMALE

   But then I see this error to set it itself  "Error with message "Criteria type can not be targeted."   Can you please let me know where I am going wrong ?


Thanks and Regards,
Vinutha Nayak


Google Ads API Forum Advisor Prod

unread,
Jul 9, 2019, 3:05:56 PM7/9/19
to nayakv...@gmail.com, adwor...@googlegroups.com

Hi Vinutha,

Could you please reply privately to author your CID and the report query you are currently using so that I can take a closer look?
 

Thanks,
Anthony
Google Ads API Team



ref:_00D1U1174p._5001UCanIe:ref

Vinutha Nayak

unread,
Jul 24, 2019, 3:37:59 AM7/24/19
to AdWords API and Google Ads API Forum
Hi Anthony,

I have replied with requested details couple of days back ?  Did you have a  chance to check on that please ?


Thanks and Regards,
Vinutha Nayak

Google Ads API Forum Advisor Prod

unread,
Jul 25, 2019, 2:31:10 PM7/25/19
to nayakv...@gmail.com, adwor...@googlegroups.com
Hi Vinutha,

Yes, I replied to your message. Here is how I responded:
I don't see any issues with your query. Can you send the request sample?

Regards,

Anthony
Google Ads API Team


ref:_00D1U1174p._5001UCanIe:ref
Reply all
Reply to author
Forward
0 new messages