Once Demographic Criterion is set it cannot be changed

311 views
Skip to first unread message

Filip Pećanac

unread,
Nov 2, 2021, 5:09:47 AM11/2/21
to AdWords API and Google Ads API Forum
Hi,

When I add Demographic AdGroupCriterion via API, lets say exclude all male users from targeting, it works fine. For this, i use this code.

But later on, once I try to include the male population for that Ad Group (by removing 'negative'=>true line of code), I receive the following message:

Fatal error: Uncaught Google\ApiCore\ApiException: { "message": "Request contains an invalid argument.", "code": 3, "status": "INVALID_ARGUMENT", "details": [ { "@type": 0, "data": "type.googleapis.com\/google.ads.googleads.v8.errors.GoogleAdsFailure" }, { "@type": 0, "data": [ { "errorCode": { "fieldError": "IMMUTABLE_FIELD" }, "message": "The field attempted to be mutated is immutable.", "location": { "fieldPathElements": [ { "fieldName": "operations", "index": 0 }, { "fieldName": "create" }, { "fieldName": "negative" in /XYZ/google-ads-php/vendor/google/gax/src/ApiException.php on line 139

Is there a way to update AdGroupCriterions once they are previously added?

Google Ads API Forum Advisor

unread,
Nov 2, 2021, 9:12:38 AM11/2/21
to filip....@oneassessment.com, adwor...@googlegroups.com
Hi Filip,

Negative is immutable. To switch a criterion from positive to negative, remove then re-add it.

Regards,

Google Logo
Aryeh Baker
Google Ads API Team
 


ref:_00D1U1174p._5004Q2QHCsx:ref

Filip Pećanac

unread,
Nov 2, 2021, 4:01:03 PM11/2/21
to AdWords API and Google Ads API Forum
Hi Aryeh,

Thanks for the response.

Let me just clarify the situation step by step, so that you can understand it better and let me know if I haven't done something properly:

1. I create an adGroup via API (automatically all age ranges are selected)
2. I use negative criterion to exclude one of the ranges, lets say 35 to 44 - I check it on Google Ads interface and it works fine
3. I try to re-include this age range by simply removing this line 'negative' => true and then i get the "Immutable field" message
4. I can continue unselecting age ranges with step no2, but when I try to include them again i get the same message

So, instead of step 3 what should I do to be able to accomplish this?

Ps. From your previous response I wasn't sure what I was supposed to do, so that's why I am back here :)

Regards,
Filip

Google Ads API Forum Advisor

unread,
Nov 3, 2021, 4:30:12 AM11/3/21
to filip....@oneassessment.com, adwor...@googlegroups.com

Hi Filip,

This is Yasar and I work with Aryeh. Let me assist you with this.

Kindly note that the negative field in AdGroupCriterion is immutable. That said, re-including said age range by simply removing line 'negative' => true from your code won’t work and you will get the "Immutable field" message since the 'negative' field is immutable.

To avoid this error, I recommend you to remove the existing AdGroupCriterion first, then re-add it by setting 'negative' => false in your code. 

Hope this helps. Let us know if you have any further questions.

Regards,

Google Logo
Yasar
Google Ads API Team
 


ref:_00D1U1174p._5004Q2QHCsx:ref

Filip Pećanac

unread,
Nov 3, 2021, 5:17:51 AM11/3/21
to AdWords API and Google Ads API Forum
Hi Yasar,

Thanks for the assistance.

So once I create an AdGroup via API all Demographic criterions are selected by default.

What would be your suggestions (or an example if you could provide) in order to:

1. Exclude certain Criterion via API?
2. Re-include that Criterion via API?

Whenever I try to accomplish the second step, I get the "immutable filed" message.

Sorry to bother you, but I am new in this, so it might take me a while to get it done properly :)

Regards,
Filip

Google Ads API Forum Advisor

unread,
Nov 3, 2021, 10:39:43 PM11/3/21
to filip....@oneassessment.com, adwor...@googlegroups.com
Hi Filip,

Thank you for your follow up, our team would be happy to help. You may refer to my responses below :


1. Exclude certain Criterion via API?

You can CREATE the AdGroupCriterion with the negative=true, if you wish to initially exclude a specific criterion.


2. Re-include that Criterion via API?

If by re-include what you meant is to target the initially excluded the criterion, you will first need to perform a REMOVE operation for the excluded criterion. You can then CREATE that criterion again, with the same details, but now with negative=false.

Best regards,


Reminder: Share your feedback about the Google Ads (AdWords) API! Take the 2021 Google Ads API and AdWords API Annual Survey
 
Google Logo
Peter Laurence Napa Oliquino
Google Ads API Team
 


ref:_00D1U1174p._5004Q2QHCsx:ref

Filip Pećanac

unread,
Nov 4, 2021, 8:01:01 AM11/4/21
to AdWords API and Google Ads API Forum
Hi Peter,

Thank you very much!

I have followed your suggestions and now everything works great.

Thanks for your time!

Regards,
Filip

Reply all
Reply to author
Forward
0 new messages