examples/AdWords/v201809/ShoppingCampaigns/AddSmartShoppingAd.php
private static function createSmartCampaign(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        $budgetId,
        $merchantId
    ) {
        $campaignService =
            $adWordsServices->get($session, CampaignService::class);

        // Create a campaign with required and optional settings.
        $campaign = new Campaign();
        $campaign->setName('Smart Shopping campaign #' . uniqid());
        // The advertisingChannelType is what makes this a Shopping campaign.
        $campaign->setAdvertisingChannelType(AdvertisingChannelType::SHOPPING);
        // Sets the advertisingChannelSubType to SHOPPING_GOAL_OPTIMIZED_ADS to
        // make this a Smart Shopping campaign.
        $campaign->setAdvertisingChannelSubType(
            AdvertisingChannelSubType::SHOPPING_GOAL_OPTIMIZED_ADS
        );
        // Recommendation: Set the campaign to PAUSED when creating it to stop
        // the ads from immediately serving. Set to ENABLED once you've added
        // targeting and the ads are ready to serve.
        $campaign->setStatus(CampaignStatus::PAUSED);

        // Set a budget.
        $budget = new Budget();
        $budget->setBudgetId($budgetId);
        $campaign->setBudget($budget);

        // Set a bidding strategy. Only MAXIMIZE_CONVERSION_VALUE is supported.
        $biddingStrategyConfiguration = new BiddingStrategyConfiguration();
        $biddingStrategyConfiguration->setBiddingStrategyType(
            BiddingStrategyType::MAXIMIZE_CONVERSION_VALUE
        );

        $campaign->setBiddingStrategyConfiguration(
            $biddingStrategyConfiguration
        );

        // All Shopping campaigns need a ShoppingSetting.
        $shoppingSetting = new ShoppingSetting();
        $shoppingSetting->setSalesCountry('US');
        $shoppingSetting->setMerchantId($merchantId);
        $campaign->setSettings([$shoppingSetting]);

        // Create a campaign operation and add it to the operations list.
        $operation = new CampaignOperation();
        $operation->setOperand($campaign);
        $operation->setOperator(Operator::ADD);

        // Create the campaign on the server and print out some information.
        $addedCampaign = $campaignService->mutate([$operation])->getValue()[0];
        printf(
            "Smart Shopping campaign with name '%s' and ID %d was added.%s",
            $addedCampaign->getName(),
            $addedCampaign->getId(),
            PHP_EOL
        );

        return $addedCampaign->getId();
    }
private static function createSmartCampaign(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        $budgetId,
        $merchantId
    ) {
        $campaignService =
            $adWordsServices->get($session, CampaignService::class);

        // Create a campaign with required and optional settings.
        $campaign = new Campaign();
        $campaign->setName('Smart Shopping campaign #' . uniqid());
        // The advertisingChannelType is what makes this a Shopping campaign.
        $campaign->setAdvertisingChannelType(AdvertisingChannelType::SHOPPING);
        // Sets the advertisingChannelSubType to SHOPPING_GOAL_OPTIMIZED_ADS to
        // make this a Smart Shopping campaign.
        $campaign->setAdvertisingChannelSubType(
            AdvertisingChannelSubType::SHOPPING_GOAL_OPTIMIZED_ADS
        );
        // Recommendation: Set the campaign to PAUSED when creating it to stop
        // the ads from immediately serving. Set to ENABLED once you've added
        // targeting and the ads are ready to serve.
        $campaign->setStatus(CampaignStatus::PAUSED);

        // Set a budget.
        $budget = new Budget();
        $budget->setBudgetId($budgetId);
        $campaign->setBudget($budget);

        // Set a bidding strategy. Only MAXIMIZE_CONVERSION_VALUE is supported.
        $biddingStrategyConfiguration = new BiddingStrategyConfiguration();
        $biddingStrategyConfiguration->setBiddingStrategyType(
            BiddingStrategyType::MAXIMIZE_CONVERSION_VALUE
        );

        $campaign->setBiddingStrategyConfiguration(
            $biddingStrategyConfiguration
        );

        // All Shopping campaigns need a ShoppingSetting.
        $shoppingSetting = new ShoppingSetting();
        $shoppingSetting->setSalesCountry('US');
        $shoppingSetting->setMerchantId($merchantId);
        $campaign->setSettings([$shoppingSetting]);

        // Create a campaign operation and add it to the operations list.
        $operation = new CampaignOperation();
        $operation->setOperand($campaign);
        $operation->setOperator(Operator::ADD);

        // Create the campaign on the server and print out some information.
        $addedCampaign = $campaignService->mutate([$operation])->getValue()[0];
        printf(
            "Smart Shopping campaign with name '%s' and ID %d was added.%s",
            $addedCampaign->getName(),
            $addedCampaign->getId(),
            PHP_EOL
        );

        return $addedCampaign->getId();
    }
private static function createSmartCampaign ( AdWordsServices $ adWordsServices , AdWordsSession $ session , $ budgetId , $ merchantId ) { $ campaignService = $ adWordsServices -> get ( $ session , CampaignService :: class ) ; // Create a campaign with required and optional settings. $ campaign = new Campaign ( ) ; $ campaign -> setName ( 'Smart Shopping campaign #' . uniqid ( ) ) ; // The advertisingChannelType is what makes this a Shopping campaign. $ campaign -> setAdvertisingChannelType ( AdvertisingChannelType :: SHOPPING ) ; // Sets the advertisingChannelSubType to SHOPPING_GOAL_OPTIMIZED_ADS to // make this a Smart Shopping campaign. $ campaign -> setAdvertisingChannelSubType ( AdvertisingChannelSubType :: SHOPPING_GOAL_OPTIMIZED_ADS ) ; // Recommendation: Set the campaign to PAUSED when creating it to stop // the ads from immediately serving. Set to ENABLED once you've added // targeting and the ads are ready to serve. $ campaign -> setStatus ( CampaignStatus :: PAUSED ) ; // Set a budget. $ budget = new Budget ( ) ; $ budget -> setBudgetId ( $ budgetId ) ; $ campaign -> setBudget ( $ budget ) ; // Set a bidding strategy. Only MAXIMIZE_CONVERSION_VALUE is supported. $ biddingStrategyConfiguration = new BiddingStrategyConfiguration ( ) ; $ biddingStrategyConfiguration -> setBiddingStrategyType ( BiddingStrategyType :: MAXIMIZE_CONVERSION_VALUE ) ; $ campaign -> setBiddingStrategyConfiguration ( $ biddingStrategyConfiguration ) ; // All Shopping campaigns need a ShoppingSetting. $ shoppingSetting = new ShoppingSetting ( ) ; $ shoppingSetting -> setSalesCountry ( 'US' ) ; $ shoppingSetting -> setMerchantId ( $ merchantId ) ; $ campaign -> setSettings ( [ $ shoppingSetting ] ) ; // Create a campaign operation and add it to the operations list. $ operation = new CampaignOperation ( ) ; $ operation -> setOperand ( $ campaign ) ; $ operation -> setOperator ( Operator :: ADD ) ; // Create the campaign on the server and print out some information. $ addedCampaign = $ campaignService -> mutate ( [ $ operation ] ) -> getValue ( ) [ 0 ] ; printf ( "Smart Shopping campaign with name '%s' and ID %d was added.%s" , $ addedCampaign -> getName ( ) , $ addedCampaign -> getId ( ) , PHP_EOL ) ; return $ addedCampaign -> getId ( ) ; }
Creates a Smart Shopping campaign.

@param AdWordsServices $adWordsServices the AdWords services
@param AdWordsSession $session the AdWords session
@param int $budgetId the budget ID
@param int $merchantId the Merchant center ID
@return int the created campaign ID
Creates a Smart Shopping campaign .