Unable to create Universal App Campaigns with the new Google Ads API (operation_access_denied_error)

37 views
Skip to first unread message

Milan van Dijck

unread,
Mar 24, 2020, 9:08:02 AM3/24/20
to AdWords API and Google Ads API Forum
For the past three days I have been trying to get Campaign creation for Universal App Campaigns working on my test MCC account. My client is programmed in PHP I have added the code below. I am using the Google Client API for PHP to do my requests via GRPC.
I have followed the following guide to get the right settings for a Universal App Campaign: https://developers.google.com/google-ads/api/docs/app-campaigns/create-campaign

I have tried:
  • Removing every field one-by-one to but this always results in an error saying a necessary field is missing. (except for the start & end date fields)
  • Removing all optional fields
  • Creating a search campaign (which works fine)
But whatever I do, I always get the following error:
GoogleAdsException: operation_access_denied_error, This operation is not permitted on this campaign
- or -
An error that says a required field is missing.

There is just nothing left I can think of to solve the error above without removing fields that are required to make an App campaign. It would be very helpful if the error specified which operation was not permitted.

(I am using the V3 objects from the googleads/google-ads-php composer package at version 3.1.0)

$customerId = "4708071192";

try {
    /* @var GoogleAdsClient $googleAdsClient */

    // Generate a refreshable OAuth2 credential for authentication.
    $oAuth2Credential = (new OAuth2TokenBuilder())->fromFile(GOOGLE_ADS_SETTINGS)->build();

    // Construct a Google Ads client configured from a properties file and the
    // OAuth2 credentials above.
    $googleAdsClient = (new GoogleAdsClientBuilder())
        ->fromFile(GOOGLE_ADS_SETTINGS)
        ->withOAuth2Credential($oAuth2Credential)
        ->build();

    // Create the budget
    $budget = new CampaignBudget();
    $budget->setName(new StringValue(['value' => 'Universal App Campaign test budget [' . uniqid() . ']']))
        ->setDeliveryMethod(BudgetDeliveryMethod::STANDARD)
        ->setAmountMicros(new Int64Value(['value' => 500000]))
        ->setExplicitlyShared(new BoolValue(['value' => false]));

    // Creates a campaign budget operation.
    $campaignBudgetOperation = new CampaignBudgetOperation();
    $campaignBudgetOperation->setCreate($budget);

    // Issues a mutate request.
    $campaignBudgetServiceClient = $googleAdsClient->getCampaignBudgetServiceClient();
    $response = $campaignBudgetServiceClient->mutateCampaignBudgets(
        $customerId,
        [$campaignBudgetOperation]
    );

    $addedBudget = $response->getResults()[0];
    $budgetResourceName = $addedBudget->getResourceName();

    // Create the bidding strategy
    $strategy = new BiddingStrategy();
    $strategy->setName(new StringValue(['value' => "testingStrategy19"]));
    $targetcpa = new TargetCpa();
    $targetcpa->setTargetCpaMicros(new Int64Value(['value' => 10000]));
    $strategy->setTargetCpa($targetcpa);

    $biddingStrategyOperation = new BiddingStrategyOperation();
    $biddingStrategyOperation->setCreate($strategy);

    // Issues a mutate request.
    $campaignBudgetServiceClient = $googleAdsClient->getBiddingStrategyServiceClient();
    $response = $campaignBudgetServiceClient->mutateBiddingStrategies(
        $customerId,
        [$biddingStrategyOperation]
    );
    $addedBudget = $response->getResults()[0];
    $biddingStrategy = $addedBudget->getResourceName();

    // Create the campaign object
    $startDate = new StringValue(['value' => date('Ymd', strtotime("2020-4-1"))]);
    $endDate = new StringValue(['value' => date('Ymd', strtotime("2020-4-10"))]);

    $campaignObject = new Campaign();
    $campaignObject->setName(new StringValue(['value' => 'Universal App Campaign Test [' . uniqid() . ']']))
        ->setAdvertisingChannelType(AdvertisingChannelType::MULTI_CHANNEL)
        ->setStatus(CampaignStatus::PAUSED)
        ->setCampaignBudget(new StringValue(['value' => $budgetResourceName]))
        ->setStartDate($startDate)
        ->setEndDate($endDate)
        ->setAdvertisingChannelSubType(AdvertisingChannelSubType::APP_CAMPAIGN)
        ->setBiddingStrategy(new StringValue(['value' => $biddingStrategy]))
        ->setBiddingStrategyType(\Google\Ads\GoogleAds\V3\Enums\BiddingStrategyTypeEnum\BiddingStrategyType::TARGET_CPA);

    $appCampaignSetting = new AppCampaignSetting();
    $appCampaignSetting->setBiddingStrategyGoalType(AppCampaignBiddingStrategyGoalType::OPTIMIZE_INSTALLS_TARGET_INSTALL_COST);
    $appCampaignSetting->setAppId(new StringValue(['value' => "com.nakko.android.nl100"]));
    $appCampaignSetting->setAppStore(AppCampaignAppStore::GOOGLE_APP_STORE);

    $campaignObject->setAppCampaignSetting($appCampaignSetting);

    // Creates a campaign operation.
    $campaignOperation = new CampaignOperation();
    $campaignOperation->setCreate($campaignObject);

    // Define campaign operations to be executed
    $campaignOperations = [];
    $campaignOperations[] = $campaignOperation;

    $campaignServiceClient = $googleAdsClient->getCampaignServiceClient();
    $response = $campaignServiceClient->mutateCampaigns($customerId, $campaignOperations, ['partialFailure' => false]);
    $result = [];
    $campaignId = 0;
    foreach ($response->getResults() as $addedCampaign) {
        $campaignId = $addedCampaign->getResourceName();
        $result[] = [
            "resourceName" => $addedCampaign->getResourceName()
        ];
    }

    echo $campaignId;

} catch (GoogleAdsException $googleAdsException) {
    $errors = [];
    foreach ($googleAdsException->getGoogleAdsFailure()->getErrors() as $error) {
        $errors[] = [
            "code" => $error->getErrorCode()->getErrorCode(),
            "message" => $error->getMessage()
        ];

    }
    $errorString = "";

    foreach($errors as $error) {
        $errorString = $errorString.implode(", ", $error);
    }

    throw new Exception("GoogleAdsException: ".$errorString);
} catch (ApiException $apiException) {
    throw new Exception("ApiException: ".$apiException->getMessage());
} catch (Exception $exception){
    throw $exception;
}


Google Ads API Forum Advisor Prod

unread,
Mar 24, 2020, 2:24:55 PM3/24/20
to mi...@livewallgroup.com, adwor...@googlegroups.com
Hi Milan,

Thank you for reaching out. Can you please share the complete detailed request and response logs for the call via Reply privately to author so that I can further investigate the issue? You can find information on enabling logging here (log level NOTICE). Make sure you are making the call using a client account and not an MCC account.

Regards,
Mitchell
Google Ads API Team

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