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
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
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
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 ?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