Device targeting via Google Ads API

144 views
Skip to first unread message

Ferenc Sijat

unread,
Feb 8, 2024, 4:52:55 PM2/8/24
to Google Ads API and AdWords API Forum
Hello,

We've been using the following code to target device:

 $operations[] = new MutateOperation([
                    'campaign_criterion_operation' => new CampaignCriterionOperation([
                        'create' => new CampaignCriterion([
                            'campaign' => ResourceNames::forCampaign($customer_id, $campaign_temp_id),
                            'type' => CriterionType::DEVICE,
                            'negative' => false,
                            'device' => new DeviceInfo([
                                'type' => Device::value($device)
                            ])
                        ])
                    ])
                ]);

$service_client = $ads_client->getGoogleAdsServiceClient();
        $response = $service_client->mutate(
            $customer_id,
            $operations
 );

But for whatever reason, when we check the campaign created in Google Ads, under device targeting, we get all devices:

Screen Shot 2024-02-08 at 3.24.38 PM.png

Everything else seems to be working correctly, as other parameters are correctly set. What can we do?


Best,
Ferenc

Google Ads API Forum Advisor

unread,
Feb 8, 2024, 9:11:44 PM2/8/24
to fer...@vct.net, adwor...@googlegroups.com
Hi Fernec,

Thank you for reaching out to the Google Ads API support team.

By reviewing your concern, I understand that you're attempting to adjust campaign targeting by using the "Criteria" but you're not observing any modifications in the campaign's targeting specifics. Can you please share under which Enums you have added the device targeting and what you are able to find from the UI. In order to investigate your issue further, kindly provide us with the complete successful API logs (request and response with request-id and request header) along with the uncropped UI screenshot generated at your end.

If you are using a client library and haven't enabled the logging yet, I would request you to enable logging for the specific client library that you are using. You can refer to the guide PHP to enable logging at your end. For REST interface requests, you can enable logging via the curl command by using the -i flag.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02ryy84:ref"

Thanks,
 
Google Logo Google Ads API Team


Ferenc Sijat

unread,
Feb 12, 2024, 1:21:29 PM2/12/24
to Google Ads API and AdWords API Forum

Currently using the latest API version for PHP (V15). We are trying to specify a campaign’s ‘Devices’ setting, adding it as a ‘Campaign Criterion’ (ref. https://developers.google.com/google-ads/api/reference/rpc/v15/CampaignCriterion).The operation is inside a list of operations as it follows: 

// Adapted from extract code for testing values based on class Device

// Google\Ads\GoogleAds\V15\Enums\DeviceEnum\Device.php

$operations = [];

$devices = ['MOBILE', 'TABLET']; 

foreach ($devices as $device) {

$operations[] = new MutateOperation([

'campaign_criterion_operation' => new CampaignCriterionOperation([

'create' => new CampaignCriterion([

'campaign' => ResourceNames::forCampaign($customer_id, $campaign_temp_id),

'type' => CriterionType::DEVICE,

'negative' => false,

'status' => CampaignCriterionStatus::value('ENABLED'),

//'bid_modifier' => 0.5,

'device' => new DeviceInfo([

'type' => Device::value($device)

])

])

])

]);

}


$service_client = $ads_client->getGoogleAdsServiceClient();

$response = $service_client->mutate($customer_id, $operations);

 

The actions for those ‘Devices’ operations run normally, without showing any error, it even returns a resource name. The thing here is that, the change doesn’t seems to be shown as expected on the Google UI.

Current behavior

image_2024_02_12T18_16_38_818Z.png
Expected behavior based on selected options
image_2024_02_12T18_16_55_009Z.png

The available options are set based on ‘DeviceEnum\Device.php’ (ref. https://github.com/googleads/google-ads-php/blob/main/src/Google/Ads/GoogleAds/V15/Enums/DeviceEnum/Device.php).


Google Ads API Forum Advisor

unread,
Feb 12, 2024, 5:01:39 PM2/12/24
to fer...@vct.net, adwor...@googlegroups.com

Hi,

Thank you for getting back to us.

Upon checking the provided code, I found that you are using the 'type' field in the request. Kindly note that property ‘type’ is an output-only property. Do not use it in the request.

Please try to include valid input properties in the request. I would recommend you check campaignCriteria to know the valid and invalid input fields in the request with respect to campaign criteria.

If you are still getting the same issue, even after following the above documentation,please get back to us with complete API logs (request and response with request-id and request header) generated at your end.

Kindly note that you have to enable logging if you are using a client library. You can refer to the guides Java, .Net, PHP, Python, Ruby or Perl to enable logging at your end. For REST interface requests, you can enable logging via the curl command by using the -i flag. 

Reply all
Reply to author
Forward
0 new messages