How to Update or Remove a Campaign Audience in Google ads API PHP

69 views
Skip to first unread message

Vigneshwaran C

unread,
Jan 23, 2023, 6:22:12 AM1/23/23
to Google Ads API and AdWords API Forum
i have tried to Remove the campaign audience but not working. can you pls help me to solve. i tried same thing us campaign language and location its working. but audience is not working.

$googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();
            $query ='SELECT campaign_criterion.user_interest.user_interest_category FROM campaign_audience_view WHERE campaign.id = '.$google_campaignId;
            $stream = $googleAdsServiceClient->Search($customerId, $query);
            $audience_remove = [];
            foreach ($stream->iterateAllElements() as $googleAdsRow) {
                $u_id = str_replace('customers/$customer_id/userInterests/', '', $googleAdsRow->getCampaignCriterion()->getUserInterest()->getUserInterestCategory());
                $audience_operation = new CampaignCriterionOperation();
$audience_remove[] = $audience_operation->setRemove($googleAdsRow->getCampaignCriterion()->getUserInterest()->getUserInterestCategory());
            }

$campaignServiceClient = $googleAdsClient->getCampaignCriterionServiceClient();
            $response = $campaignServiceClient->mutateCampaignCriteria(
                $customerId,
                $audience_remove
            );


Vigneshwaran C

unread,
Jan 23, 2023, 9:36:21 AM1/23/23
to Google Ads API and AdWords API Forum
error on audience remove.jpg

Google Ads API Forum Advisor

unread,
Jan 23, 2023, 2:46:00 PM1/23/23
to vignes...@constient.com, adwor...@googlegroups.com

Hi Vigneshwaran,
 

Thanks for reaching out to the Google Ads API team. I hope you are doing well today.
 

With regards to your concern, you’ve encountered RESOURCE_NOT_FOUND error, this means that the requested resource is not found. So that our team can take a closer look at the error you encountered and provide accurate specific recommendations on the issue, could you share your complete request and response logs that generated on your end.


You can provide it via Reply privately to the author option. If this option is not available, then send it instead on this email address googleadsa...@google.com.


Regards,

Google Logo
Darwin
Google Ads API Team
 



ref:_00D1U1174p._5004Q2iMZ8Y:ref
Reply all
Reply to author
Forward
0 new messages