Device setting (php)

81 views
Skip to first unread message

mYama

unread,
Jul 11, 2018, 5:39:58 PM7/11/18
to AdWords API and Google Ads API Forum

Hello

If you want to configure only mobile web and tablet web in campaign device settings, how do you write it?

Thank you

Luis Xander Talag (AdWords API Team)

unread,
Jul 12, 2018, 1:27:52 AM7/12/18
to AdWords API and Google Ads API Forum
Hi,

Are you referring to targeting the mobile and tablet device to your campaign? If so, you may use the CampaignCriterionService and use the Platform criterion to target the mobile and tablet device. You may refer to this guide for their respective criterion id. Also, you may refer to this sample code in PHP on how to add a criteria to your campaign. However, that sample code used Location and Language criteria.  All you need to do is to change the criterion object to Platform.

Feel free to write back for any clarifications.

Thanks and regards,
Luis
AdWords API Team

mYama

unread,
Jul 13, 2018, 4:00:22 AM7/13/18
to AdWords API and Google Ads API Forum
Hello
Thank you Luis.


I tried coding as shown below using Platform, but an error will be returned.

error contents:
OperatorError.OPERATOR_NOT_SUPPORTED @ operations [1] .operand.criterion; trigger: 'CriterionId {id = 30000}', OperatorError.OPERATOR_NOT_SUPPORTED @ operations [2] .operand.criterion; trigger: 'CriterionId {id = 30001}


Coding content:
    $ platform = new Platform ();
    $ platform-> setId (30000);
    // $ platform-> setPlatformName ('Desktop');
    $ campaignCriteria [] = new CampaignCriterion ($ campaignId, null, $ platform);

    // HighEndMobile
    $ platform = new Platform ();
    $ platform-> setId (30001);
    // $ platform-> setPlatformName ('HighEndMobile');
    $ campaignCriteria [] = new CampaignCriterion ($ campaignId, null, $ platform);

    // Tablet
    $ platform = new Platform ();
    $ platform-> setId (30002);
    // $ platform-> setPlatformName ('Tablet');
    $ campaignCriteria [] = new CampaignCriterion ($ campaignId, null, $ platform);

    $ operations = [];
    foreach ($ campaignCriteria as $ campaignCriterion) {
      $ operation = new CampaignCriterionOperation ();
      $ operation-> setOperator (Operator :: ADD);
      $ operation-> setOperand ($ campaignCriterion);
      $ operations [] = $ operation;
    }

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

Thank you

2018年7月12日木曜日 14時27分52秒 UTC+9 Luis Xander Talag (AdWords API Team):

Luis Xander Talag (AdWords API Team)

unread,
Jul 13, 2018, 5:39:01 AM7/13/18
to AdWords API and Google Ads API Forum
Hi,

My apologies for the confusion. Since by default new campaigns already contains a platform criterion for each of Desktop, HighEndMobile, and Tablet then, to make changes on this criterion, you should use the SET operator instead. If you still encountered the error after trying my suggestions, please provide the complete SOAP request and response logs so I could further investigate the issue. You may check this guide on how the logging works in PHP client library.

Regards,
Luis
AdWords API Team
Reply all
Reply to author
Forward
0 new messages