Google Ads API : Unable to add campaign level Device targeting using client library

126 views
Skip to first unread message

alok

unread,
Sep 3, 2019, 6:25:26 AM9/3/19
to AdWords API and Google Ads API Forum
Hi,

I am trying to add campaign targets using java client library but getting below error while adding device targets.I followed the approach mentioned in Google Ads API examples

Note that location and proximity targets are getting added successfully but device targets returns error "OPERATOR_NOT_SUPPORTED_FOR_CRITERION_TYPE"
Is there bug in google Ads API while adding device targets, if yes any timelines when it will be resolved or is there any problem in below request.

Request and Response are below:

Request
-------
MethodName: google.ads.googleads.v2.services.CampaignCriterionService/MutateCampaignCriteria
Endpoint: googleads.googleapis.com:443
Headers: {developer-token=TOKEN, login-customer-id=xxxxxxxxxx, x-goog-api-client=gl-java/1.8.0_201 gapic/ gax/1.45.0 grpc/1.21.0}
Body: customer_id: "yyyyyyyyyy"
operations {
  create {
    campaign {
      value: "customers/yyyyyyyyyy/campaigns/aaaaaaaaaa"
    }
    criterion_id {
      value: 30001
    }
    negative {
    }
    device {
      type: MOBILE
    }
    bid_modifier {
      value: 4.5
    }
  }
}
operations {
  create {
    campaign {
      value: "customers/yyyyyyyyyy/campaigns/aaaaaaaaaa"
    }
    negative {
    }
    bid_modifier {
      value: 3.4
    }
    proximity {
      geo_point {
        longitude_in_micro_degrees {
          value: -178337050
        }
        latitude_in_micro_degrees {
          value: 28422800
        }
      }
      radius {
        value: 10.0
      }
      radius_units: KILOMETERS
    }
  }
}
operations {
  create {
    campaign {
      value: "customers/yyyyyyyyyy/campaigns/aaaaaaaaaa"
    }
    criterion_id {
      value: 21132
    }
    negative {
    }
    location {
      geo_target_constant {
        value: "geoTargetConstants/21132"
      }
    }
    bid_modifier {
      value: 2.3
    }
  }
}
operations {
  create {
    campaign {
      value: "customers/yyyyyyyyyy/campaigns/aaaaaaaaaa"
    }
    criterion_id {
      value: 21133
    }
    negative {
    }
    location {
      geo_target_constant {
        value: "geoTargetConstants/21133"
      }
    }
    bid_modifier {
      value: 1.2
    }
  }
}
partial_failure: true


Response
--------
Headers: Metadata(content-disposition=attachment,content-type=application/grpc,request-id=7Cs-1xvq5XYUgPAj4vQ4jA,date=Fri, 30 Aug 2019 10:09:06 GMT,alt-svc=quic=":443"; ma=2592000; v="46,43,39")
Body: results {
}
results {
  resource_name: "customers/yyyyyyyyyy/campaignCriteria/aaaaaaaaaa~810693935922"
}
results {
  resource_name: "customers/yyyyyyyyyy/campaignCriteria/aaaaaaaaaa~21132"
}
results {
  resource_name: "customers/yyyyyyyyyy/campaignCriteria/aaaaaaaaaa~21133"
}
partial_failure_error {
  code: 3
  message: "This operator cannot be applied to a criterion of this type., at operations[0].create.device"
  details {
    type_url: "type.googleapis.com/google.ads.googleads.v2.errors.GoogleAdsFailure"
    value: "\nm\n\003\350\001\t\022<This operator cannot be applied to a criterion of this type.\032\002*\000\"$\022\016\n\noperations\022\000\022\b\n\006create\022\b\n\006device"
  }
}

Failure message: null
Status: Status{code=OK, description=null, cause=null}.

2019-08-30 10:09:08,867 [main] INFO  c.t.s.c.g.i.s.CampaignTargetServiceClient - Add campaign targets operation 0 failed for account yyyyyyyyyy with errors: [error_code {
  campaign_criterion_error: OPERATOR_NOT_SUPPORTED_FOR_CRITERION_TYPE
}
message: "This operator cannot be applied to a criterion of this type."
trigger {
  string_value: ""
}
location {
  field_path_elements {
    field_name: "operations"
    index {
    }
  }
  field_path_elements {
    field_name: "create"
  }
  field_path_elements {
    field_name: "device"
  }
}
]

Thanks,
Alok

Google Ads API Forum Advisor Prod

unread,
Sep 4, 2019, 12:29:10 PM9/4/19
to aloks...@gmail.com, adwor...@googlegroups.com
Hi Alok, 

The device criteria for each device implicitly exists in each campaign, so you won't be able to ADD or REMOVE those criteria. However, you can use bid modifiers to opt out of a specific device or set the bid modifier for a specific device. For example, if you want to exclude tablets, you can use campaign_criterion update operation with bid_modifier value as zero. Could you please take a look and let me know if you have any further questions?

Thanks,
Bharani, Google Ads API Team

ref:_00D1U1174p._5001UHFSnF:ref

alok

unread,
Sep 5, 2019, 5:54:42 AM9/5/19
to AdWords API and Google Ads API Forum
Hi Bharani,

Thanks for the suggestion. I used update operations and was able to update bid modifiers for Mobile,Tablet and Desktop devices but was not able to update bid modifier for Connected_TV device target. I am using criterionId of CONNECTED_TV as 30004 but request fails with "Resource was not found" error with trigger string_value: "CriterionId{id=30004}"

Isn't criterionId 30004 correct value for CONNECTED_TV. Can you point me to any documents which specifies correct criterionIds for all devices.

Request
-------
MethodName: google.ads.googleads.v2.services.CampaignCriterionService/MutateCampaignCriteria
Endpoint: googleads.googleapis.com:443
Headers: {developer-token=TOKEN, login-customer-id=xxxxxxxxxx, x-goog-api-client=gl-java/1.8.0_201 gapic/ gax/1.45.0 grpc/1.21.0}
Body: customer_id: "yyyyyyyyyy"
operations {
  update {
    resource_name: "customers/yyyyyyyyyy/campaignCriteria/zzzzzzzzzz~30004"
    campaign {
      value: "customers/yyyyyyyyyy/campaigns/zzzzzzzzzz"
    }
    criterion_id {
      value: 30004
    }
    negative {
    }
    device {
      type: CONNECTED_TV
    }
    bid_modifier {
      value: 4.5
    }
  }
  update_mask {
    paths: "bid_modifier"
  }
}
partial_failure: true


Response
--------
Headers: Metadata(content-disposition=attachment,content-type=application/grpc,request-id=xfa-FSqq-vQBvKXT_siBwA,date=Thu, 05 Sep 2019 09:36:06 GMT,alt-svc=quic=":443"; ma=2592000; v="46,43,39")
Body: results {
}
partial_failure_error {
  code: 3
  message: "Resource was not found., at operations[0]."
  details {
    type_url: "type.googleapis.com/google.ads.googleads.v2.errors.GoogleAdsFailure"
    value: "\nH\n\0028\003\022\027Resource was not found.\032\027*\025CriterionId{id=30004}\"\020\022\016\n\noperations\022\000"

  }
}

Failure message: null
Status: Status{code=OK, description=null, cause=null}.

2019-09-05 09:36:06,466 [main] INFO  c.t.s.c.g.i.s.CampaignTargetServiceClient - Google add campaign targets operation 0 failed for account yyyyyyyyyy with errors: [error_code {
  mutate_error: RESOURCE_NOT_FOUND
}
message: "Resource was not found."
trigger {
  string_value: "CriterionId{id=30004}"

}
location {
  field_path_elements {
    field_name: "operations"
    index {
    }
  }
}
]

Thanks,
Alok

Google Ads API Forum Advisor Prod

unread,
Sep 5, 2019, 3:39:09 PM9/5/19
to aloks...@gmail.com, adwor...@googlegroups.com
Hi Alok, 

Based on the request shared, it looks like the resource name is not formed correctly. I have included the code snippet in Java along with the logs for your reference. Could you please take a look and let me know if you encounter any issues? You can share the API request and response logs using Reply privately to author option.
Sample_Logs.rtf

Google Ads API Forum Advisor Prod

unread,
Sep 6, 2019, 4:04:42 PM9/6/19
to aloks...@gmail.com, adwor...@googlegroups.com
Hi Alok, 

Thank you for sharing the complete logs. It looks like you're updating the targeting criteria for a search campaign. You will be able to target or exclude and adjust the bids for the Connected TV criteria only for Display/Video campaigns. Please refer to this blog post for more information. Could you please give this a try for one of the Display campaigns and let us know if you encounter any issues?

Regards,

alok

unread,
Sep 9, 2019, 4:23:26 AM9/9/19
to AdWords API and Google Ads API Forum
Thanks Bharani,

Updating Connected_TV device criteria works for display and video campaigns.

Regards,
Alok
Reply all
Reply to author
Forward
0 new messages