Search in sources :

Example 11 with BiddingStrategyConfiguration

use of com.google.api.ads.adwords.jaxws.v201809.cm.BiddingStrategyConfiguration in project googleads-java-lib by googleads.

the class ProductPartitionTreeImpl method getBid.

/**
 * Returns the criterion-level bid, or null if no such bid exists.
 */
private static Money getBid(BiddableAdGroupCriterion biddableCriterion) {
    BiddingStrategyConfiguration biddingConfig = biddableCriterion.getBiddingStrategyConfiguration();
    Money cpcBidAmount = null;
    if (biddingConfig.getBids() != null) {
        for (Bids bid : biddingConfig.getBids()) {
            if (bid instanceof CpcBid) {
                CpcBid cpcBid = (CpcBid) bid;
                if (BidSource.CRITERION.equals(cpcBid.getCpcBidSource())) {
                    cpcBidAmount = cpcBid.getBid();
                    break;
                }
            }
        }
    }
    return cpcBidAmount;
}
Also used : Money(com.google.api.ads.adwords.axis.v201809.cm.Money) BiddingStrategyConfiguration(com.google.api.ads.adwords.axis.v201809.cm.BiddingStrategyConfiguration) Bids(com.google.api.ads.adwords.axis.v201809.cm.Bids) CpcBid(com.google.api.ads.adwords.axis.v201809.cm.CpcBid)

Example 12 with BiddingStrategyConfiguration

use of com.google.api.ads.adwords.jaxws.v201809.cm.BiddingStrategyConfiguration in project googleads-java-lib by googleads.

the class ProductPartitionTreeImpl method createNonEmptyAdGroupTree.

/**
 * Returns a new tree based on a non-empty collection of ad group criteria. All parameters
 * required.
 *
 * @param adGroupId the ID of the ad group
 * @param parentIdMap the multimap from parent product partition ID to child criteria
 * @return a new ProductPartitionTree
 */
private static ProductPartitionTreeImpl createNonEmptyAdGroupTree(Long adGroupId, ListMultimap<Long, AdGroupCriterion> parentIdMap) {
    Preconditions.checkNotNull(adGroupId, "Null ad group ID");
    Preconditions.checkArgument(!parentIdMap.isEmpty(), "parentIdMap passed for ad group ID %s is empty", adGroupId);
    Preconditions.checkArgument(parentIdMap.containsKey(null), "No root criterion found in the list of ad group criteria for ad group ID %s", adGroupId);
    AdGroupCriterion rootCriterion = Iterables.getOnlyElement(parentIdMap.get(null));
    Preconditions.checkState(rootCriterion instanceof BiddableAdGroupCriterion, "Root criterion for ad group ID %s is not a BiddableAdGroupCriterion", adGroupId);
    BiddableAdGroupCriterion biddableRootCriterion = (BiddableAdGroupCriterion) rootCriterion;
    BiddingStrategyConfiguration biddingStrategyConfig = biddableRootCriterion.getBiddingStrategyConfiguration();
    Preconditions.checkState(biddingStrategyConfig != null, "Null bidding strategy config on the root node of ad group ID %s", adGroupId);
    ProductPartitionNode rootNode = new ProductPartitionNode(null, (ProductDimension) null, rootCriterion.getCriterion().getId(), new ProductDimensionComparator());
    // Set the root's bid if a bid exists on the BiddableAdGroupCriterion.
    Money rootNodeBid = getBid(biddableRootCriterion);
    if (rootNodeBid != null) {
        rootNode = rootNode.asBiddableUnit().setBid(rootNodeBid.getMicroAmount());
    }
    rootNode = rootNode.setTrackingUrlTemplate(biddableRootCriterion.getTrackingUrlTemplate());
    rootNode = copyCustomParametersToNode(biddableRootCriterion, rootNode);
    addChildNodes(rootNode, parentIdMap);
    return new ProductPartitionTreeImpl(adGroupId, biddingStrategyConfig, rootNode);
}
Also used : Money(com.google.api.ads.adwords.axis.v201809.cm.Money) BiddableAdGroupCriterion(com.google.api.ads.adwords.axis.v201809.cm.BiddableAdGroupCriterion) BiddingStrategyConfiguration(com.google.api.ads.adwords.axis.v201809.cm.BiddingStrategyConfiguration) BiddableAdGroupCriterion(com.google.api.ads.adwords.axis.v201809.cm.BiddableAdGroupCriterion) AdGroupCriterion(com.google.api.ads.adwords.axis.v201809.cm.AdGroupCriterion)

Example 13 with BiddingStrategyConfiguration

use of com.google.api.ads.adwords.jaxws.v201809.cm.BiddingStrategyConfiguration in project googleads-java-lib by googleads.

the class ProductPartitionNodeAdapterTest method setUp.

@Before
public void setUp() throws Exception {
    adGroupId = -1L;
    biddingConfig = new BiddingStrategyConfiguration();
    biddingConfig.setBiddingStrategyId(-2L);
    parentNode = new ProductPartitionNode(null, null, -3L, new ProductDimensionComparator());
    childNode = new ProductPartitionNode(parentNode, ProductDimensions.createBrand("google"), -4L, new ProductDimensionComparator());
}
Also used : BiddingStrategyConfiguration(com.google.api.ads.adwords.axis.v201809.cm.BiddingStrategyConfiguration) Before(org.junit.Before)

Example 14 with BiddingStrategyConfiguration

use of com.google.api.ads.adwords.jaxws.v201809.cm.BiddingStrategyConfiguration in project googleads-java-lib by googleads.

the class JaxWsBatchJobUploadBodyProviderTest method addCampaignOperation.

@Override
protected void addCampaignOperation(BatchJobMutateRequest request, long campaignId, String campaignName, String status, String advertisingChannelType, long budgetId, String biddingStrategyType, boolean enhancedCpcEnabled) {
    Campaign campaign = new Campaign();
    campaign.setId(campaignId);
    campaign.setName(campaignName);
    campaign.setStatus(CampaignStatus.valueOf(status));
    campaign.setAdvertisingChannelType(AdvertisingChannelType.valueOf(advertisingChannelType));
    Budget budget = new Budget();
    budget.setBudgetId(budgetId);
    campaign.setBudget(budget);
    BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration();
    biddingStrategyConfiguration.setBiddingStrategyType(BiddingStrategyType.valueOf(biddingStrategyType));
    ManualCpcBiddingScheme cpcBiddingScheme = new ManualCpcBiddingScheme();
    cpcBiddingScheme.setEnhancedCpcEnabled(enhancedCpcEnabled);
    biddingStrategyConfiguration.setBiddingScheme(cpcBiddingScheme);
    campaign.setBiddingStrategyConfiguration(biddingStrategyConfiguration);
    CampaignOperation operation = new CampaignOperation();
    operation.setOperand(campaign);
    operation.setOperator(Operator.ADD);
    request.addOperation(operation);
}
Also used : Campaign(com.google.api.ads.adwords.jaxws.v201809.cm.Campaign) BiddingStrategyConfiguration(com.google.api.ads.adwords.jaxws.v201809.cm.BiddingStrategyConfiguration) CampaignOperation(com.google.api.ads.adwords.jaxws.v201809.cm.CampaignOperation) Budget(com.google.api.ads.adwords.jaxws.v201809.cm.Budget) ManualCpcBiddingScheme(com.google.api.ads.adwords.jaxws.v201809.cm.ManualCpcBiddingScheme)

Example 15 with BiddingStrategyConfiguration

use of com.google.api.ads.adwords.jaxws.v201809.cm.BiddingStrategyConfiguration in project googleads-java-lib by googleads.

the class AddUniversalAppCampaign method runExample.

/**
 * Runs the example.
 *
 * @param adWordsServices the services factory.
 * @param session the session.
 * @throws ApiException if the API request failed with one or more service errors.
 * @throws RemoteException if the API request failed due to other errors.
 */
public static void runExample(AdWordsServicesInterface adWordsServices, AdWordsSession session) throws RemoteException {
    // Get the CampaignService.
    CampaignServiceInterface campaignService = adWordsServices.get(session, CampaignServiceInterface.class);
    // Create the campaign.
    Campaign campaign = new Campaign();
    campaign.setName("Interplanetary Cruise App #" + System.currentTimeMillis());
    // Recommendation: Set the campaign to PAUSED when creating it to prevent
    // 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 the advertising channel and subchannel types for universal app campaigns.
    campaign.setAdvertisingChannelType(AdvertisingChannelType.MULTI_CHANNEL);
    campaign.setAdvertisingChannelSubType(AdvertisingChannelSubType.UNIVERSAL_APP_CAMPAIGN);
    // Set the campaign's bidding strategy. universal app campaigns
    // only support TARGET_CPA bidding strategy.
    BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration();
    biddingConfig.setBiddingStrategyType(BiddingStrategyType.TARGET_CPA);
    // Set the target CPA to $1 / app install.
    TargetCpaBiddingScheme biddingScheme = new TargetCpaBiddingScheme();
    biddingScheme.setTargetCpa(new Money());
    biddingScheme.getTargetCpa().setMicroAmount(1000000L);
    biddingConfig.setBiddingScheme(biddingScheme);
    campaign.setBiddingStrategyConfiguration(biddingConfig);
    // Set the campaign's budget.
    campaign.setBudget(new Budget());
    campaign.getBudget().setBudgetId(createBudget(adWordsServices, session));
    // Optional: Set the start date.
    campaign.setStartDate(DateTime.now().plusDays(1).toString("yyyyMMdd"));
    // Optional: Set the end date.
    campaign.setEndDate(DateTime.now().plusYears(1).toString("yyyyMMdd"));
    // Set the campaign's assets and ad text ideas. These values will be used to
    // generate ads.
    UniversalAppCampaignSetting universalAppSetting = new UniversalAppCampaignSetting();
    universalAppSetting.setAppId("com.labpixies.colordrips");
    universalAppSetting.setAppVendor(MobileApplicationVendor.VENDOR_GOOGLE_MARKET);
    universalAppSetting.setDescription1("A cool puzzle game");
    universalAppSetting.setDescription2("Remove connected blocks");
    universalAppSetting.setDescription3("3 difficulty levels");
    universalAppSetting.setDescription4("4 colorful fun skins");
    // Optional: You can set up to 20 image assets for your campaign.
    // See UploadImage.java for an example on how to upload images.
    // 
    // universalAppSetting.setImageMediaIds(new long[] { INSERT_IMAGE_MEDIA_ID_HERE });
    // Optimize this campaign for getting new users for your app.
    universalAppSetting.setUniversalAppBiddingStrategyGoalType(UniversalAppBiddingStrategyGoalType.OPTIMIZE_FOR_INSTALL_CONVERSION_VOLUME);
    // If you select the OPTIMIZE_FOR_IN_APP_CONVERSION_VOLUME goal type, then also specify
    // your in-app conversion types so AdWords can focus your campaign on people who are
    // most likely to complete the corresponding in-app actions.
    // Conversion type IDs can be retrieved using ConversionTrackerService.get.
    // 
    // campaign.selectiveOptimization = new SelectiveOptimization();
    // campaign.selectiveOptimization.conversionTypeIds =
    // new long[] { INSERT_CONVERSION_TYPE_ID_1_HERE, INSERT_CONVERSION_TYPE_ID_2_HERE };
    // Optional: Set the campaign settings for Advanced location options.
    GeoTargetTypeSetting geoSetting = new GeoTargetTypeSetting();
    geoSetting.setPositiveGeoTargetType(GeoTargetTypeSettingPositiveGeoTargetType.LOCATION_OF_PRESENCE);
    geoSetting.setNegativeGeoTargetType(GeoTargetTypeSettingNegativeGeoTargetType.DONT_CARE);
    campaign.setSettings(new Setting[] { universalAppSetting, geoSetting });
    // Create the operation.
    CampaignOperation operation = new CampaignOperation();
    operation.setOperand(campaign);
    operation.setOperator(Operator.ADD);
    CampaignOperation[] operations = new CampaignOperation[] { operation };
    // Add the campaign.
    CampaignReturnValue result = campaignService.mutate(operations);
    // Display the results.
    for (Campaign newCampaign : result.getValue()) {
        System.out.printf("Universal app campaign with name '%s' and ID %d was added.%n", newCampaign.getName(), newCampaign.getId());
        // Optional: Set the campaign's location and language targeting. No other targeting
        // criteria can be used for universal app campaigns.
        setCampaignTargetingCriteria(newCampaign, adWordsServices, session);
    }
}
Also used : Money(com.google.api.ads.adwords.axis.v201809.cm.Money) CampaignServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.CampaignServiceInterface) Campaign(com.google.api.ads.adwords.axis.v201809.cm.Campaign) UniversalAppCampaignSetting(com.google.api.ads.adwords.axis.v201809.cm.UniversalAppCampaignSetting) BiddingStrategyConfiguration(com.google.api.ads.adwords.axis.v201809.cm.BiddingStrategyConfiguration) CampaignOperation(com.google.api.ads.adwords.axis.v201809.cm.CampaignOperation) CampaignReturnValue(com.google.api.ads.adwords.axis.v201809.cm.CampaignReturnValue) Budget(com.google.api.ads.adwords.axis.v201809.cm.Budget) TargetCpaBiddingScheme(com.google.api.ads.adwords.axis.v201809.cm.TargetCpaBiddingScheme) GeoTargetTypeSetting(com.google.api.ads.adwords.axis.v201809.cm.GeoTargetTypeSetting)

Aggregations

BiddingStrategyConfiguration (com.google.api.ads.adwords.axis.v201809.cm.BiddingStrategyConfiguration)21 Money (com.google.api.ads.adwords.axis.v201809.cm.Money)12 CampaignOperation (com.google.api.ads.adwords.axis.v201809.cm.CampaignOperation)10 CpcBid (com.google.api.ads.adwords.axis.v201809.cm.CpcBid)10 Budget (com.google.api.ads.adwords.axis.v201809.cm.Budget)9 Campaign (com.google.api.ads.adwords.axis.v201809.cm.Campaign)9 CampaignServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.CampaignServiceInterface)7 AdGroupCriterion (com.google.api.ads.adwords.axis.v201809.cm.AdGroupCriterion)6 BiddableAdGroupCriterion (com.google.api.ads.adwords.axis.v201809.cm.BiddableAdGroupCriterion)6 CampaignReturnValue (com.google.api.ads.adwords.axis.v201809.cm.CampaignReturnValue)6 AdGroup (com.google.api.ads.adwords.axis.v201809.cm.AdGroup)5 AdGroupCriterionOperation (com.google.api.ads.adwords.axis.v201809.cm.AdGroupCriterionOperation)5 AdGroupCriterionServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.AdGroupCriterionServiceInterface)5 AdGroupOperation (com.google.api.ads.adwords.axis.v201809.cm.AdGroupOperation)5 AdGroupServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.AdGroupServiceInterface)4 Bids (com.google.api.ads.adwords.axis.v201809.cm.Bids)4 AdGroupCriterionReturnValue (com.google.api.ads.adwords.axis.v201809.cm.AdGroupCriterionReturnValue)3 AdGroupReturnValue (com.google.api.ads.adwords.axis.v201809.cm.AdGroupReturnValue)3 ManualCpcBiddingScheme (com.google.api.ads.adwords.axis.v201809.cm.ManualCpcBiddingScheme)3 ShoppingSetting (com.google.api.ads.adwords.axis.v201809.cm.ShoppingSetting)3