Search in sources :

Example 1 with Money

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

the class AddCompleteCampaignsUsingBatchJob method buildBudgetOperation.

private static BudgetOperation buildBudgetOperation(Iterator<Long> tempIdGenerator, String namePrefix) {
    Budget budget = new Budget();
    budget.setBudgetId(tempIdGenerator.next());
    budget.setName(String.format("Interplanetary Cruise %s", namePrefix));
    Money budgetAmount = new Money();
    budgetAmount.setMicroAmount(50000000L);
    budget.setAmount(budgetAmount);
    budget.setDeliveryMethod(BudgetBudgetDeliveryMethod.STANDARD);
    BudgetOperation budgetOperation = new BudgetOperation();
    budgetOperation.setOperand(budget);
    budgetOperation.setOperator(Operator.ADD);
    return budgetOperation;
}
Also used : Money(com.google.api.ads.adwords.axis.v201809.cm.Money) BudgetOperation(com.google.api.ads.adwords.axis.v201809.cm.BudgetOperation) Budget(com.google.api.ads.adwords.axis.v201809.cm.Budget)

Example 2 with Money

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

the class GraduateTrial method runExample.

/**
 * Runs the example.
 *
 * @param adWordsServices the services factory.
 * @param session the session.
 * @param trialId the ID of the trial to graduate.
 * @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, long trialId) throws RemoteException {
    // Get the TrialService and BudgetService.
    TrialServiceInterface trialService = adWordsServices.get(session, TrialServiceInterface.class);
    BudgetServiceInterface budgetService = adWordsServices.get(session, BudgetServiceInterface.class);
    // To graduate a trial, you must specify a different budget from the base campaign. The base
    // campaign (in order to have had a trial based on it) must have a non-shared budget, so it
    // cannot be shared with the new independent campaign created by graduation.
    Budget budget = new Budget();
    budget.setName("Budget #" + System.currentTimeMillis());
    Money budgetAmount = new Money();
    budgetAmount.setMicroAmount(50000000L);
    budget.setAmount(budgetAmount);
    budget.setDeliveryMethod(BudgetBudgetDeliveryMethod.STANDARD);
    BudgetOperation budgetOperation = new BudgetOperation();
    budgetOperation.setOperator(Operator.ADD);
    budgetOperation.setOperand(budget);
    // Add budget.
    long budgetId = budgetService.mutate(new BudgetOperation[] { budgetOperation }).getValue(0).getBudgetId();
    Trial trial = new Trial();
    trial.setId(trialId);
    trial.setBudgetId(budgetId);
    trial.setStatus(TrialStatus.GRADUATED);
    TrialOperation trialOperation = new TrialOperation();
    trialOperation.setOperator(Operator.SET);
    trialOperation.setOperand(trial);
    // Update the trial.
    trial = trialService.mutate(new TrialOperation[] { trialOperation }).getValue(0);
    // Graduation is a synchronous operation, so the campaign is already ready. If you promote
    // instead, make sure to see the polling scheme demonstrated in AddTrial.java to wait for the
    // asynchronous operation to finish.
    System.out.printf("Trial ID %d graduated. Campaign ID %d was given a new budget ID %d and " + "is no longer dependent on this trial.%n", trial.getId(), trial.getTrialCampaignId(), budgetId);
}
Also used : Money(com.google.api.ads.adwords.axis.v201809.cm.Money) TrialServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.TrialServiceInterface) Trial(com.google.api.ads.adwords.axis.v201809.cm.Trial) BudgetOperation(com.google.api.ads.adwords.axis.v201809.cm.BudgetOperation) BudgetServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.BudgetServiceInterface) Budget(com.google.api.ads.adwords.axis.v201809.cm.Budget) TrialOperation(com.google.api.ads.adwords.axis.v201809.cm.TrialOperation)

Example 3 with Money

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

the class AddDynamicSearchAdsCampaign method addWebPageCriteria.

/**
 * Adds a web page criteria to target Dynamic Search Ads.
 */
private static void addWebPageCriteria(AdWordsServicesInterface adWordsServices, AdWordsSession session, AdGroup adGroup) throws ApiException, RemoteException {
    // Get the AdGroupCriterionService.
    AdGroupCriterionServiceInterface adGroupCriterionService = adWordsServices.get(session, AdGroupCriterionServiceInterface.class);
    // Create a webpage criterion for special offers.
    WebpageParameter param = new WebpageParameter();
    param.setCriterionName("Special offers");
    WebpageCondition urlCondition = new WebpageCondition();
    urlCondition.setOperand(WebpageConditionOperand.URL);
    urlCondition.setArgument("/specialoffers");
    WebpageCondition titleCondition = new WebpageCondition();
    titleCondition.setOperand(WebpageConditionOperand.PAGE_TITLE);
    titleCondition.setArgument("Special Offer");
    param.setConditions(new WebpageCondition[] { urlCondition, titleCondition });
    Webpage webpage = new Webpage();
    webpage.setParameter(param);
    // Create biddable ad group criterion.
    BiddableAdGroupCriterion biddableAdGroupCriterion = new BiddableAdGroupCriterion();
    biddableAdGroupCriterion.setAdGroupId(adGroup.getId());
    biddableAdGroupCriterion.setCriterion(webpage);
    biddableAdGroupCriterion.setUserStatus(UserStatus.PAUSED);
    // Optional: set a custom bid.
    BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration();
    CpcBid bid = new CpcBid();
    bid.setBid(new Money());
    bid.getBid().setMicroAmount(10000000L);
    biddingStrategyConfiguration.setBids(new Bids[] { bid });
    biddableAdGroupCriterion.setBiddingStrategyConfiguration(biddingStrategyConfiguration);
    // Create operations.
    AdGroupCriterionOperation operation = new AdGroupCriterionOperation();
    operation.setOperator(Operator.ADD);
    operation.setOperand(biddableAdGroupCriterion);
    // Create the criterion.
    AdGroupCriterion newAdGroupCriterion = adGroupCriterionService.mutate(new AdGroupCriterionOperation[] { operation }).getValue(0);
    System.out.printf("Webpage criterion with ID %d was added to ad group ID %d.%n", newAdGroupCriterion.getCriterion().getId(), newAdGroupCriterion.getAdGroupId());
}
Also used : Money(com.google.api.ads.adwords.axis.v201809.cm.Money) AdGroupCriterionOperation(com.google.api.ads.adwords.axis.v201809.cm.AdGroupCriterionOperation) Webpage(com.google.api.ads.adwords.axis.v201809.cm.Webpage) AdGroupCriterionServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.AdGroupCriterionServiceInterface) 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) CpcBid(com.google.api.ads.adwords.axis.v201809.cm.CpcBid) WebpageParameter(com.google.api.ads.adwords.axis.v201809.cm.WebpageParameter) WebpageCondition(com.google.api.ads.adwords.axis.v201809.cm.WebpageCondition)

Example 4 with Money

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

the class AddDynamicSearchAdsCampaign method createAdGroup.

/**
 * Creates the ad group.
 */
private static AdGroup createAdGroup(AdWordsServicesInterface adWordsServices, AdWordsSession session, Campaign campaign) throws ApiException, RemoteException {
    // Get the AdGroupService.
    AdGroupServiceInterface adGroupService = adWordsServices.get(session, AdGroupServiceInterface.class);
    // Create the ad group.
    AdGroup adGroup = new AdGroup();
    // Required: Set the ad group's type to Dynamic Search Ads.
    adGroup.setAdGroupType(AdGroupType.SEARCH_DYNAMIC_ADS);
    adGroup.setName("Earth to Mars Cruises #" + System.currentTimeMillis());
    adGroup.setCampaignId(campaign.getId());
    adGroup.setStatus(AdGroupStatus.PAUSED);
    // Recommended: Set a tracking URL template for your ad group if you want to use URL
    // tracking software.
    adGroup.setTrackingUrlTemplate("http://tracker.example.com/traveltracker/{escapedlpurl}");
    // Set the ad group bids.
    BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration();
    CpcBid cpcBid = new CpcBid();
    cpcBid.setBid(new Money());
    cpcBid.getBid().setMicroAmount(3000000L);
    biddingConfig.setBids(new Bids[] { cpcBid });
    adGroup.setBiddingStrategyConfiguration(biddingConfig);
    // Create the operation.
    AdGroupOperation operation = new AdGroupOperation();
    operation.setOperand(adGroup);
    operation.setOperator(Operator.ADD);
    AdGroup newAdGroup = adGroupService.mutate(new AdGroupOperation[] { operation }).getValue(0);
    System.out.printf("Ad group with name '%s' and ID %d was added.%n", newAdGroup.getName(), newAdGroup.getId());
    return newAdGroup;
}
Also used : Money(com.google.api.ads.adwords.axis.v201809.cm.Money) AdGroupServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.AdGroupServiceInterface) BiddingStrategyConfiguration(com.google.api.ads.adwords.axis.v201809.cm.BiddingStrategyConfiguration) AdGroup(com.google.api.ads.adwords.axis.v201809.cm.AdGroup) CpcBid(com.google.api.ads.adwords.axis.v201809.cm.CpcBid) AdGroupOperation(com.google.api.ads.adwords.axis.v201809.cm.AdGroupOperation)

Example 5 with Money

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

the class AddDynamicSearchAdsCampaign method createBudget.

/**
 * Creates the budget.
 */
private static Budget createBudget(AdWordsServicesInterface adWordsServices, AdWordsSession session) throws RemoteException, ApiException {
    // Get the BudgetService.
    BudgetServiceInterface budgetService = adWordsServices.get(session, BudgetServiceInterface.class);
    // Create a budget, which can be shared by multiple campaigns.
    Budget sharedBudget = new Budget();
    sharedBudget.setName("Interplanetary Cruise #" + System.currentTimeMillis());
    Money budgetAmount = new Money();
    budgetAmount.setMicroAmount(50000000L);
    sharedBudget.setAmount(budgetAmount);
    sharedBudget.setDeliveryMethod(BudgetBudgetDeliveryMethod.STANDARD);
    BudgetOperation budgetOperation = new BudgetOperation();
    budgetOperation.setOperand(sharedBudget);
    budgetOperation.setOperator(Operator.ADD);
    // Add the budget
    Budget budget = budgetService.mutate(new BudgetOperation[] { budgetOperation }).getValue(0);
    return budget;
}
Also used : Money(com.google.api.ads.adwords.axis.v201809.cm.Money) BudgetOperation(com.google.api.ads.adwords.axis.v201809.cm.BudgetOperation) BudgetServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.BudgetServiceInterface) Budget(com.google.api.ads.adwords.axis.v201809.cm.Budget)

Aggregations

Money (com.google.api.ads.adwords.axis.v201809.cm.Money)30 BiddingStrategyConfiguration (com.google.api.ads.adwords.axis.v201809.cm.BiddingStrategyConfiguration)12 Budget (com.google.api.ads.adwords.axis.v201809.cm.Budget)11 CpcBid (com.google.api.ads.adwords.axis.v201809.cm.CpcBid)11 BudgetOperation (com.google.api.ads.adwords.axis.v201809.cm.BudgetOperation)10 BiddableAdGroupCriterion (com.google.api.ads.adwords.axis.v201809.cm.BiddableAdGroupCriterion)8 BudgetServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.BudgetServiceInterface)8 AdGroupCriterion (com.google.api.ads.adwords.axis.v201809.cm.AdGroupCriterion)6 AdGroup (com.google.api.ads.adwords.axis.v201809.cm.AdGroup)4 AdGroupCriterionOperation (com.google.api.ads.adwords.axis.v201809.cm.AdGroupCriterionOperation)4 AdGroupCriterionServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.AdGroupCriterionServiceInterface)4 AdGroupOperation (com.google.api.ads.adwords.axis.v201809.cm.AdGroupOperation)4 Bids (com.google.api.ads.adwords.axis.v201809.cm.Bids)4 Budget (com.google.api.ads.adwords.jaxws.v201809.cm.Budget)4 BudgetOperation (com.google.api.ads.adwords.jaxws.v201809.cm.BudgetOperation)4 Money (com.google.api.ads.adwords.jaxws.v201809.cm.Money)4 AdWordsSession (com.google.api.ads.adwords.lib.client.AdWordsSession)4 AdWordsServices (com.google.api.ads.adwords.axis.factory.AdWordsServices)3 AdGroupServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.AdGroupServiceInterface)3 CampaignOperation (com.google.api.ads.adwords.axis.v201809.cm.CampaignOperation)3