Device type, OS, Device model setup API

115 views
Skip to first unread message

denma test

unread,
Jul 22, 2020, 9:05:06 AM7/22/20
to AdWords API and Google Ads API Forum
I need code sample to setup Device, OS, Device model setup to campaign using Adwords API using PHP library v201809. PFA.
Screenshot_2020-07-22 Settings - api client - Google Ads.png

Google Ads API Forum Advisor Prod

unread,
Jul 22, 2020, 2:53:28 PM7/22/20
to denm...@gmail.com, adwor...@googlegroups.com

Hi Denma,

Thanks for reaching out. With regards to your concern,  you can target Device Type by implementing the CampaignCriterionService with criterion type Platform. The criterion IDs you shared are correct. Please see here for an example of how to add targeting criteria to a campaign.

Let me know if you have any question.

Thanks,
Nirmita Patel Google Ads Team



ref:_00D1U1174p._5004Q22YBAh:ref

denma test

unread,
Jul 27, 2020, 3:18:06 AM7/27/20
to AdWords API and Google Ads API Forum
Thanks, let me check it out. If any issues let you know. Thanks for the support.

Google Ads API Forum Advisor Prod

unread,
Jul 27, 2020, 12:40:44 PM7/27/20
to denm...@gmail.com, adwor...@googlegroups.com
Hi Denma,

Glad to help you,  If you have any additional questions or require further clarification, do not hesitate.

denma test

unread,
Aug 27, 2020, 6:37:45 AM8/27/20
to AdWords API and Google Ads API Forum
Hi
Platform criteria is not update with campaign, below is my code and it is not return any error instead provide success response only

$adWordsServices = new AdWordsServices();
$campaignCriterionService = $adWordsServices->get($session, CampaignCriterionService::class);
$campaignCriteria = [];
$operations = [];

$mobile = new Platform();
$mobile->setId(30001);
$campaignCriteria[] = new CampaignCriterion($campaignId, null, $mobile);
   
foreach ($campaignCriteria as $campaignCriterion) {
    $operation = new CampaignCriterionOperation();
    $operation->setOperator(Operator::SET);
    $operation->setOperand($campaignCriterion);
    $operations[] = $operation;
}
// Setup platform target on the server    
$result = $campaignCriterionService->mutate($operations);
But the setting is not reflected in server, however i cannot find the setting while get campaign details using selector too. Please correct if am did any mistakes.

Google Ads API Forum Advisor Prod

unread,
Aug 27, 2020, 3:06:05 PM8/27/20
to denm...@gmail.com, adwor...@googlegroups.com
Hi Denma,

Thank you for providing for information. Could you please share the complete detailed request and response logs, so that I can further investigate the issue. You can find information on enabling logging in the ReadMe of your client library.

Thanks,
Google Logo
Nirmitabahen Gaurav Patel
Google Ads API Team
 

 

ref:_00D1U1174p._5004Q22YBAh:ref

denma test

unread,
Aug 28, 2020, 7:16:31 AM8/28/20
to AdWords API and Google Ads API Forum
[2020-08-28 16:33:57] AW_SOAP.INFO: clientCustomerId=430-855-8101 operations=1 service=CampaignCriterionService method=mutate responseTime=483 requestId=0005adee0fd9b6d10a627e54090374f0 server=adwords.google.com isFault=0 faultMessage= 
[2020-08-28 16:33:57] AW_SOAP.DEBUG: POST /api/adwords/cm/v201809/CampaignCriterionService?wsdl HTTP/1.1
Host: adwords.google.com
Connection: close
User-Agent: PHP-SOAP/5.6.36-1+ubuntu14.04.1+deb.sury.org+1
Content-Type: text/xml; charset=utf-8
SOAPAction: ""
Content-Length: 924
Authorization: REDACTED

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://adwords.google.com/api/adwords/cm/v201809" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Header><ns1:RequestHeader><ns1:clientCustomerId>430-855-8101</ns1:clientCustomerId><ns1:developerToken>REDACTED</ns1:developerToken><ns1:userAgent>unknown (AwApi-PHP, googleads-php-lib/40.0.0, PHP/5.6.36-1+ubuntu14.04.1+deb.sury.org+1)</ns1:userAgent><ns1:validateOnly>false</ns1:validateOnly><ns1:partialFailure>false</ns1:partialFailure></ns1:RequestHeader></SOAP-ENV:Header><SOAP-ENV:Body><ns1:mutate><ns1:operations><ns1:operator>SET</ns1:operator><ns1:operand><ns1:campaignId>10822804484</ns1:campaignId><ns1:criterion xsi:type="ns1:Platform"><ns1:id>30001</ns1:id></ns1:criterion></ns1:operand></ns1:operations></ns1:mutate></SOAP-ENV:Body></SOAP-ENV:Envelope>

HTTP/1.1 200 OK
Content-Type: text/xml; charset=UTF-8
Date: Fri, 28 Aug 2020 11:07:43 GMT
Expires: Fri, 28 Aug 2020 11:07:43 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Content-Security-Policy: frame-ancestors 'self'
X-XSS-Protection: 1; mode=block
Server: GSE
Alt-Svc: h3-29=":443"; ma=2592000,h3-27=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
Accept-Ranges: none
Vary: Accept-Encoding
Connection: close
Transfer-Encoding: chunked

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header><ResponseHeader xmlns="https://adwords.google.com/api/adwords/cm/v201809"><requestId>0005adee0fd9b6d10a627e54090374f0</requestId><serviceName>CampaignCriterionService</serviceName><methodName>mutate</methodName><operations>1</operations><responseTime>483</responseTime></ResponseHeader></soap:Header><soap:Body><mutateResponse xmlns="https://adwords.google.com/api/adwords/cm/v201809"><rval><ListReturnValue.Type>CampaignCriterionReturnValue</ListReturnValue.Type><value><campaignId>10822804484</campaignId><isNegative>false</isNegative><criterion xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Platform"><id>30001</id><type>PLATFORM</type><Criterion.Type>Platform</Criterion.Type><platformName>HighEndMobile</platformName></criterion><campaignCriterionStatus>ACTIVE</campaignCriterionStatus><CampaignCriterion.Type>CampaignCriterion</CampaignCriterion.Type></value></rval></mutateResponse></soap:Body></soap:Envelope>
 
There is no error in API call but no relection in UI

Google Ads API Forum Advisor Prod

unread,
Aug 28, 2020, 3:22:26 PM8/28/20
to denm...@gmail.com, adwor...@googlegroups.com
Hi Denma,

Thank you for providing information. My team is further investigating the issue and will let you know when there's an update.

Google Ads API Forum Advisor Prod

unread,
Aug 31, 2020, 10:34:26 AM8/31/20
to denm...@gmail.com, adwor...@googlegroups.com
Hi Denma,

I took a look at the code snippet you provided and I noticed that you use the operator SET, could you give it another try using the operator ADD instead?

Thanks,
Pierrick - Google Ads API Team

ref:_00D1U1174p._5004Q22YBAh:ref

denma test

unread,
Sep 1, 2020, 2:20:52 AM9/1/20
to AdWords API and Google Ads API Forum
Hi
I have tried already with ADD, getting belwo error while using ADD operator

Array ( [status] => error [message] => Error in platform targeting [data] => Array ( [errorResponse] => [OperatorError.OPERATOR_NOT_SUPPORTED @ operations[0].operand.criterion; trigger:'CriterionId{id=30001}'] [errorMsg] => OPERATOR_NOT_SUPPORTED ) )

Google Ads API Forum Advisor Prod

unread,
Sep 1, 2020, 7:22:56 PM9/1/20
to denm...@gmail.com, adwor...@googlegroups.com
Hi Denma,

Sorry I misled you in my previous message, you are right, SET is the operator to use here.

I was able to set a Platform criteria to target mobile phone devices for a campaign that initially had it disabled in the settings. I did it using the following code in PHP:
 
        $campaignCriterionService = $adWordsServices->get($session, CampaignCriterionService::class);
        
        // Add a device criterion.
        $mobile = new Platform();
        $mobile->setId(30001);
        $mobileCriterion = new CampaignCriterion(
            $campaignId,
            null,
            $mobile,
            5,
            CampaignCriterionCampaignCriterionStatus::ACTIVE
        );

        $operation = new CampaignCriterionOperation();
        $operation->setOperator(Operator::SET);
        $operation->setOperand($mobileCriterion);
        $operations[] = $operation;

        $result = $campaignCriterionService->mutate($operations);

Once executed, I refreshed the Google Ads UI completely and could see it reflected at two locations under my campaign:
  • "Devices" menu on the left: the bid adjustment for the "Mobile phones" device is now +400%
  • In the campaign settings: under "Devices" I can see that "Mobile phones" is now selected
Could you share more detail about the initial campaign targeting settings? Also, what exact modifications do you expect to see after a successful API call and where on the UI?

Thanks,

ref:_00D1U1174p._5004Q22YBAh:ref

denma test

unread,
Sep 2, 2020, 7:52:34 AM9/2/20
to AdWords API and Google Ads API Forum
Let me try with this code and get back to you.
Reply all
Reply to author
Forward
0 new messages