Hi Anthony, Awesome, this example helped me to create a working Device Bid Modifier at campaign level. I attach the working code in case someone else finds it useful. Many thanks for your help and have a nice day!
Kind regards, Christoph Am Donnerstag, 21. März 2019 18:51:55 UTC+1 schrieb googleadsapi-forumadvisor: > > Hi Christoph, > > Please have a look at this example > <https://github.com/googleads/google-ads-php/blob/master/examples/BasicOperations/UpdateKeyword.php#L116>. > > It shows how to update a keyword which you can use a reference on how to > define the resource name. > > Regards, > Anthony > 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/ > =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ > > On 03/21/19 07:57:51 [email protected] <javascript:> wrote: > > Hello Anthony, > > Many thanks for your reply! > > As you suggested I tried to use the CampaignCriterionService > <https://developers.google.com/google-ads/api/docs/targeting/criteria#campaign_criteria>, > > and have the following code. It gives me an error message > "Resource_Name_Missing", but I am unsure how to add this parameter. I tried > to include it in several ways but was not successful. Maybe you can help me > out? > > Again, many thanks for your help! > > Kind regards, > > Christoph > > private static function createDeviceCampaignCriterionOperation( > $languageId, > $campaignResourceName > ) { > $campaignCriterion = new CampaignCriterion([ > 'campaign' => new StringValue(['value' => > $campaignResourceName]), > 'device' => new DeviceInfo (['type' => Device::MOBILE]), > 'bid_modifier' => new FloatValue(['value' => '2']) > ]); > return new CampaignCriterionOperation(['update' => > $campaignCriterion]); > } > > > *Error Message:* > ApiException was thrown with message '{ "message": "Request contains an > invalid argument.", "code": 3, "status": "INVALID_ARGUMENT", "details": [ { > "@type": 0, "data": > "type.googleapis.com\/google.ads.googleads.v0.errors.GoogleAdsFailure" > }, { "@type": 0, "data": [ { "errorCode": { "requestError": > "RESOURCE_NAME_MISSING" }, "message": "Resource name is missing.", > "location": { "fieldPathElements": [ { "fieldName": "operations", "index": > "0" }, { "fieldName": "update" }, { "fieldName": "resource_name" } ] } } ] > } ] }'. > > > Am Mittwoch, 20. März 2019 16:52:06 UTC+1 schrieb > googleadsapi-forumadvisor: > > Hello Christoph, > > The only criteria type you can adjust bid modifiers for using > CampaignBidModifierService > <https://developers.google.com/google-ads/api/docs/targeting/bid-modifiers#campaign_bid_modifiers> > are > CALLS. If you want to adjust device bid modifiers, you will need to use the > CampaignCriterionService > <https://developers.google.com/google-ads/api/docs/targeting/criteria#campaign_criteria> > to adjust the CampaignCriterion > <https://developers.google.com/google-ads/api/reference/rpc/google.ads.googleads.v1.resources#google.ads.googleads.v1.resources.CampaignCriterion> > . > > Regards, > Anthony > 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/ > =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ > > On 03/20/19 05:30:16 [email protected] wrote: > > Hello, > > I am trying to create a mobile and tablet bid modifier at campaign level, > using the new Ads API Beta. I used the example "AddAdGroupBidModifier.php" > from the examples library and tried to modify it to do the same function at > campaign level, but I receive an error message. > > Does anyone know how to solve this? Or is there any further documentation > or an example to see how to build the request? > > Many thanks in advance, > > Christoph > > > *This is part of my code where I define the request: (Full code in the > attachment)* > > $CampaignBidModifier = new CampaignBidModifier([ > 'campaign' => new StringValue( > ['value' => ResourceNames::forCampaign($customerId, > $CampaignId)] > ), > 'bid_modifier' => new DoubleValue(['value' => > $bidModifierValue]), > 'device' => new DeviceInfo(['type' => Device::MOBILE]) > ]); > > > > *This is the error that I get:* > > *Fatal error*: Uncaught UnexpectedValueException: Invalid message > property: device in /www/htdocs/w01745db/api. > thegoodtraffic.com/google-ads-php-master/vendor/google/ > protobuf/src/Google/Protobuf/Internal/Message.php:992 Stack trace: #0 > /www/htdocs/w01745db/api.thegoodtraffic.com/google-ads- > php-master/vendor/google/protobuf/src/Google/Protobuf/ > Internal/Message.php(79): > Google\Protobuf\Internal\Message->mergeFromArray(Array) > #1 /www/htdocs/w01745db/api.thegoodtraffic.com/google-ads- > php-master/src/Google/Ads/GoogleAds/V0/Resources/ > CampaignBidModifier.php(70): > Google\Protobuf\Internal\Message->__construct(Array) > #2 /www/htdocs/w01745db/api.thegoodtraffic.com/google-ads- > php-master/api/management/AddCampaignBidModifier.php(122): > Google\Ads\GoogleAds\V0\Resources\CampaignBidModifier->__construct(Array) > #3 /www/htdocs/w01745db/api.thegoodtraffic.com/google-ads- > php-master/api/management/AddCampaignBidModifier.php(74): > Google\Ads\GoogleAds\Management\AddCampaignBidModifier:: > runExample(Object(Google\Ads\GoogleAds\Lib\GoogleAdsClient), in > */www/htdocs/w01745db/api.thegoodtraffic.com/google-ads-php-master/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php > > <http://api.thegoodtraffic.com/google-ads-php-master/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php>* > > on line *992* > > -- > -- > =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ > 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 [email protected] > To unsubscribe from this group, send email to > [email protected] > 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 [email protected]. > 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/abb48e4b-49ef-49d0-9be5-5142f80583ce%40googlegroups.com > <https://groups.google.com/d/msgid/adwords-api/abb48e4b-49ef-49d0-9be5-5142f80583ce%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > > -- > -- > =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ > 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 [email protected] > To unsubscribe from this group, send email to > [email protected] > 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 [email protected]. > 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/4425933a-8d43-422c-b1b0-696706e6ae48%40googlegroups.com > > <https://groups.google.com/d/msgid/adwords-api/4425933a-8d43-422c-b1b0-696706e6ae48%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > > -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ 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 [email protected] To unsubscribe from this group, send email to [email protected] 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 [email protected]. 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/ec617fb3-d4d1-4219-bb46-2b6ef0eca9e3%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
<<attachment: UpdateDeviceBidModifiers.php>>
