examples/AdWords/v201809/ShoppingCampaigns/AddShoppingCampaignForShowcaseAds.php
private static function createAdGroup(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        Campaign $campaign
    ) {
        $adGroupService = $adWordsServices->get($session, AdGroupService::class);

        // Create ad group.
        $adGroup = new AdGroup();
        $adGroup->setCampaignId($campaign->getId());
        $adGroup->setName('Ad Group #' . uniqid());

        // Required: Set the ad group type to SHOPPING_SHOWCASE_ADS.
        $adGroup->setAdGroupType(AdGroupType::SHOPPING_SHOWCASE_ADS);

        // Required: Set the ad group's bidding strategy configuration.
        // Note: Showcase ads require that the campaign has a ManualCpc
        // BiddingStrategyConfiguration.
        $biddingStrategyConfiguration = new BiddingStrategyConfiguration();

        // Optional: Set the bids.
        $bidAmount = new Money();
        $bidAmount->setMicroAmount(100000);
        $cpcBid = new CpcBid();
        $cpcBid->setBid($bidAmount);
        $biddingStrategyConfiguration->setBids([$cpcBid]);

        $adGroup->setBiddingStrategyConfiguration($biddingStrategyConfiguration);

        // Create operation.
        $adGroupOperation = new AdGroupOperation();
        $adGroupOperation->setOperand($adGroup);
        $adGroupOperation->setOperator(Operator::ADD);

        // Make the mutate request.
        $adGroupAddResult = $adGroupService->mutate([$adGroupOperation]);
        $adGroup = $adGroupAddResult->getValue()[0];

        return $adGroup;
    }
private static function createAdGroup(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        Campaign $campaign
    ) {
        $adGroupService = $adWordsServices->get($session, AdGroupService::class);

        // Create ad group.
        $adGroup = new AdGroup();
        $adGroup->setCampaignId($campaign->getId());
        $adGroup->setName('Ad Group #' . uniqid());

        // Required: Set the ad group type to SHOPPING_SHOWCASE_ADS.
        $adGroup->setAdGroupType(AdGroupType::SHOPPING_SHOWCASE_ADS);

        // Required: Set the ad group's bidding strategy configuration.
        // Note: Showcase ads require that the campaign has a ManualCpc
        // BiddingStrategyConfiguration.
        $biddingStrategyConfiguration = new BiddingStrategyConfiguration();

        // Optional: Set the bids.
        $bidAmount = new Money();
        $bidAmount->setMicroAmount(100000);
        $cpcBid = new CpcBid();
        $cpcBid->setBid($bidAmount);
        $biddingStrategyConfiguration->setBids([$cpcBid]);

        $adGroup->setBiddingStrategyConfiguration($biddingStrategyConfiguration);

        // Create operation.
        $adGroupOperation = new AdGroupOperation();
        $adGroupOperation->setOperand($adGroup);
        $adGroupOperation->setOperator(Operator::ADD);

        // Make the mutate request.
        $adGroupAddResult = $adGroupService->mutate([$adGroupOperation]);
        $adGroup = $adGroupAddResult->getValue()[0];

        return $adGroup;
    }
private static function createAdGroup ( AdWordsServices $ adWordsServices , AdWordsSession $ session , Campaign $ campaign ) { $ adGroupService = $ adWordsServices -> get ( $ session , AdGroupService :: class ) ; // Create ad group. $ adGroup = new AdGroup ( ) ; $ adGroup -> setCampaignId ( $ campaign -> getId ( ) ) ; $ adGroup -> setName ( 'Ad Group #' . uniqid ( ) ) ; // Required: Set the ad group type to SHOPPING_SHOWCASE_ADS. $ adGroup -> setAdGroupType ( AdGroupType :: SHOPPING_SHOWCASE_ADS ) ; // Required: Set the ad group's bidding strategy configuration. // Note: Showcase ads require that the campaign has a ManualCpc // BiddingStrategyConfiguration. $ biddingStrategyConfiguration = new BiddingStrategyConfiguration ( ) ; // Optional: Set the bids. $ bidAmount = new Money ( ) ; $ bidAmount -> setMicroAmount ( 100000 ) ; $ cpcBid = new CpcBid ( ) ; $ cpcBid -> setBid ( $ bidAmount ) ; $ biddingStrategyConfiguration -> setBids ( [ $ cpcBid ] ) ; $ adGroup -> setBiddingStrategyConfiguration ( $ biddingStrategyConfiguration ) ; // Create operation. $ adGroupOperation = new AdGroupOperation ( ) ; $ adGroupOperation -> setOperand ( $ adGroup ) ; $ adGroupOperation -> setOperator ( Operator :: ADD ) ; // Make the mutate request. $ adGroupAddResult = $ adGroupService -> mutate ( [ $ adGroupOperation ] ) ; $ adGroup = $ adGroupAddResult -> getValue ( ) [ 0 ] ; return $ adGroup ; }
Creates an ad group in the Shopping campaign.
Creates an ad group in the Shopping campaign .