update campaign target location

97 views
Skip to first unread message

Oleg Disrupt

unread,
Jun 2, 2023, 9:48:52 PM6/2/23
to Google Ads API and AdWords API Forum
Hello
I want to remove all locations in campaign and update new locations.
I tried it to use in google-php-sdk examples but some locations still exist
foreach ($locationIds as $locationId) {
            // Creates a campaign criterion.
            $campaignCriterion = new CampaignCriterion([
                'campaign' => $campaignResourceName,
                'location' => new LocationInfo([
                    'geo_target_constant' => ResourceNames::forGeoTargetConstant($locationId)
                ])
            ]);

            // Creates a campaign criterion operation.
            $campaignCriterionOperation = new CampaignCriterionOperation();
            $campaignCriterionOperation->setCreate($campaignCriterion);

            $campaignCriterionOperations[] = $campaignCriterionOperation;
        }

        // Submits the criteria operations and prints their information.
        $campaignCriterionServiceClient = $this->googleAdsClient->getCampaignCriterionServiceClient();
        $response = $campaignCriterionServiceClient->mutateCampaignCriteria(
            $customerId,
            $campaignCriterionOperations
        );

Google Ads API Forum Advisor

unread,
Jun 7, 2023, 3:31:20 AM6/7/23
to ol...@disrupt.social, adwor...@googlegroups.com

Hi Oleg,

Thank you for reaching out to us.

For our team to further check this and provide appropriate recommendations to you, could you please provide us with the complete API logs (request, response, and requestID) generated on your end?

Note that logs can be requested or provided to the developer handling the Google Ads API transactions when logging of the API requests has been enabled. You may check here the specific guidelines on how to enable PHP : https://developers.google.com/google-ads/api/docs/client-libs/php/logging

You may then send the requested information via the Reply privately to author option. If this option is not available, you may send the details directly to our googleadsa...@google.com alias instead.​ ​ ​ ​ ​ ​ ​ ​

On the other hand, if you are indeed want to update the location on your campaign criterion, then you may indeed use the CampaignCriterionService (https://developers.google.com/google-ads/api/reference/rpc/v13/CampaignCriterionServiceand update(https://developers.google.com/google-ads/api/reference/rpc/v13/CampaignCriterionOperation#updateyour CampaignCriterion(https://developers.google.com/google-ads/api/reference/rpc/v13/CampaignCriterion).

Kindly note that the field update_mask(https://developers.google.com/google-ads/api/reference/rpc/v13/CampaignCriterionOperation#update_mask) is the one that determines which resource fields are modified in an update.
 

This message is in relation to case "ref:_00D1U1174p._5004Q2lwOPW:ref"

Thanks,
 
Google Logo Google Ads API Team


Reply all
Reply to author
Forward
0 new messages