Package com.google.api.adwords.v201306.cm

Examples of com.google.api.adwords.v201306.cm.CampaignServiceInterface


      // Get AdWordsUser from "~/adwords.properties".
      AdWordsUser user = new AdWordsUser();

      // Get the validation CampaignService.
      CampaignServiceInterface campaignService =
          user.getService(AdWordsService.V201309.CAMPAIGN_SERVICE);

      Long campaignId = Long.parseLong("INSERT_CAMPAIGN_ID_HERE");

      // Create selector.
      Selector selector = new Selector();
      selector.setFields(new String[] {"Id", "Name", "Eligible", "RejectionReasons"});

      // Create predicates.
      Predicate campaignIdPredicate =
          new Predicate("CampaignId", PredicateOperator.IN, new String[] {campaignId.toString()});
      selector.setPredicates(new Predicate[] {campaignIdPredicate});

      // Get campaigns.
      CampaignPage page = campaignService.get(selector);

      // Display campaigns.
      if (page.getEntries() != null) {
        for (Campaign campaign : page.getEntries()) {
          if (campaign.getConversionOptimizerEligibility().getEligible()) {
View Full Code Here


   */
  private static Campaign createCampaignWithBiddingStrategy(
      AdWordsUser user, Long biddingStrategyId, Long sharedBudgetId)
      throws ApiException, RemoteException, ServiceException {
    // Get the CampaignService, which loads the required classes.
    CampaignServiceInterface campaignService =
        user.getService(AdWordsService.V201309.CAMPAIGN_SERVICE);

    // Create campaign.
    Campaign campaign = new Campaign();
    campaign.setName("Interplanetary Cruise #" + System.currentTimeMillis());

    // Set the budget.
    Budget budget = new Budget();
    budget.setBudgetId(sharedBudgetId);
    campaign.setBudget(budget);

    // Set bidding strategy (required).
    BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration();
    biddingStrategyConfiguration.setBiddingStrategyId(biddingStrategyId);

    campaign.setBiddingStrategyConfiguration(biddingStrategyConfiguration);

    // Set keyword matching setting (required).
    KeywordMatchSetting keywordMatchSetting = new KeywordMatchSetting();
    keywordMatchSetting.setOptIn(true);
    campaign.setSettings(new Setting[] {keywordMatchSetting});

    // Set network targeting (recommended).
    NetworkSetting networkSetting = new NetworkSetting();
    networkSetting.setTargetGoogleSearch(true);
    networkSetting.setTargetSearchNetwork(true);
    networkSetting.setTargetContentNetwork(true);
    campaign.setNetworkSetting(networkSetting);

    // Create operation.
    CampaignOperation operation = new CampaignOperation();
    operation.setOperand(campaign);
    operation.setOperator(Operator.ADD);

    CampaignReturnValue result = campaignService.mutate(new CampaignOperation[] {operation});
    Campaign newCampaign = result.getValue(0);

    System.out.printf("Campaign with name '%s', ID %d and bidding scheme ID %d was created.\n",
        newCampaign.getName(), newCampaign.getId(),
        newCampaign.getBiddingStrategyConfiguration().getBiddingStrategyId());
View Full Code Here

      // Get AdWordsUser from "~/adwords.properties".
      AdWordsUser user = new AdWordsUser();

      // Get the CampaignService.
      CampaignServiceInterface campaignService =
          user.getService(AdWordsService.V201309.CAMPAIGN_SERVICE);

      // Create selector.
      Selector selector = new Selector();
      selector.setFields(new String[] {"Id", "Name"});
      selector.setOrdering(new OrderBy[] {new OrderBy("Name", SortOrder.ASCENDING)});
     
      // Get all campaigns.
      CampaignPage page = campaignService.get(selector);

      // Display campaigns.
      if (page.getEntries() != null) {
        for (Campaign campaign : page.getEntries()) {
          System.out.println("Campaign with name \"" + campaign.getName() + "\" and id \""
View Full Code Here

      // Get AdWordsUser from "~/adwords.properties".
      AdWordsUser user = new AdWordsUser();

      // Get the CampaignService.
      CampaignServiceInterface campaignService =
          user.getService(AdWordsService.V201309.CAMPAIGN_SERVICE);

      // Create selector.
      Selector selector = new Selector();
      selector.setFields(new String[] {"Id", "Name", "Status"});
      selector.setOrdering(new OrderBy[] {new OrderBy("Name", SortOrder.ASCENDING)});

      // Create predicates.
      Predicate statusPredicate =
          new Predicate("Status", PredicateOperator.IN, new String[] {"PAUSED"});
      selector.setPredicates(new Predicate[] {statusPredicate});

      // Get all paused campaigns.
      CampaignPage page = campaignService.get(selector);

      // Display campaigns.
      if (page.getEntries() != null) {
        for (Campaign campaign : page.getEntries()) {
          System.out.println("Campaign with name \"" + campaign.getName() + "\", id \""
View Full Code Here

      // Get AdWordsUser from "~/adwords.properties".
      AdWordsUser user = new AdWordsUser();

      // Get the CampaignService.
      CampaignServiceInterface campaignService =
          user.getService(AdWordsService.V201309.CAMPAIGN_SERVICE);

      // Get the CustomerSyncService.
      CustomerSyncServiceInterface customerSyncService =
          user.getService(AdWordsService.V201309.CUSTOMER_SYNC_SERVICE);

      // Get a list of all campaign IDs.
      List<Long> campaignIds = new ArrayList<Long>();
      Selector selector = new Selector();
      selector.setFields(new String[] {"Id"});
      CampaignPage campaigns = campaignService.get(selector);
      if (campaigns.getEntries() != null) {
        for (Campaign campaign : campaigns.getEntries()) {
          campaignIds.add(campaign.getId());
        }
      }
View Full Code Here

      // Get AdWordsUser from "~/adwords.properties".
      AdWordsUser user = new AdWordsUser();

      // Get the validation CampaignService.
      CampaignServiceInterface campaignValidationService =
          user.getValidationService(AdWordsService.V201309.CAMPAIGN_SERVICE);

      // Create campaign.
      Campaign goodCampaign = new Campaign();
      goodCampaign.setName("Campaign #" + System.currentTimeMillis());
      goodCampaign.setStatus(CampaignStatus.PAUSED);
      BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration();
      ManualCpcBiddingScheme manualCpc = new ManualCpcBiddingScheme();
      manualCpc.setEnhancedCpcEnabled(false);
      biddingConfig.setBiddingScheme(manualCpc);
      goodCampaign.setBiddingStrategyConfiguration(biddingConfig);

      // Create budget.
      Budget budget = new Budget();
      budget.setPeriod(BudgetBudgetPeriod.DAILY);
      budget.setAmount(new Money(null, 50000000L));
      budget.setDeliveryMethod(BudgetBudgetDeliveryMethod.STANDARD);
      goodCampaign.setBudget(budget);

      KeywordMatchSetting keywordMatch = new KeywordMatchSetting();
      keywordMatch.setOptIn(Boolean.TRUE);
      goodCampaign.setSettings(new Setting[] {keywordMatch});
     
      // Create operations.
      CampaignOperation operation = new CampaignOperation();
      operation.setOperand(goodCampaign);
      operation.setOperator(Operator.ADD);

      CampaignOperation[] operations = new CampaignOperation[] {operation};

      // Validate campaign add operation.
      CampaignReturnValue result = campaignValidationService.mutate(operations);

      // Display new campaigns, which should be none if the service was a
      // validation service.
      if (result != null) {
        for (Campaign campaignResult : result.getValue()) {
          System.out.println("New campaign with name \"" + campaignResult.getName() + "\" and id \""
              + campaignResult.getId() + "\" was created.");
        }
      } else {
        System.out.println("No campaigns created.");
      }

      // Provide an invalid bidding strategy that will cause an exception
      // during validation.
      Campaign badCampaign = new Campaign();
      badCampaign.setName("Campaign #" + System.currentTimeMillis());
      badCampaign.setStatus(CampaignStatus.PAUSED);
      badCampaign.setBudget(budget);

      // Throws RequiredError.REQUIRED @ operations[0].operand.biddingStrategyConfiguration.
      badCampaign.setBiddingStrategyConfiguration(null);

      // Create operations.
      operation = new CampaignOperation();
      operation.setOperand(badCampaign);
      operation.setOperator(Operator.ADD);

      operations = new CampaignOperation[] {operation};

      try {
        // Validate campaign add operation.
        result = campaignValidationService.mutate(operations);
      } catch (ApiException e) {
        System.err.println("Validation failed for reason \"" + e.getMessage1() + "\".");
      }
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

      // Get AdWordsUser from "~/adwords.properties".
      AdWordsUser user = new AdWordsUser();

      // Get the CampaignService.
      CampaignServiceInterface campaignService =
          user.getService(AdWordsService.V201309.CAMPAIGN_SERVICE);

      // Create campaign.
      Campaign campaign = new Campaign();
      campaign.setName("Interplanetary Cruise #" + System.currentTimeMillis());
      campaign.setStatus(CampaignStatus.PAUSED);
     
      // Create the bids.
      BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration();
      ManualCpcBiddingScheme manualCpc = new ManualCpcBiddingScheme();
      manualCpc.setEnhancedCpcEnabled(false);
      biddingConfig.setBiddingScheme(manualCpc);
      campaign.setBiddingStrategyConfiguration(biddingConfig);

      BudgetServiceInterface budgetService = user.getService(AdWordsService.V201309.BUDGET_SERVICE);

      // Create budget.
      Budget budget = new Budget();
      budget.setName("Interplanetary Budget #" + System.currentTimeMillis());
      budget.setPeriod(BudgetBudgetPeriod.DAILY);
      budget.setAmount(new Money(null, 50000000L));
      budget.setDeliveryMethod(BudgetBudgetDeliveryMethod.STANDARD);

      // Add budget.
      BudgetOperation budgetOperation = new BudgetOperation();
      budgetOperation.setOperand(budget);
      budgetOperation.setOperator(Operator.ADD);
      BudgetReturnValue budgetReturnValue =
          budgetService.mutate(new BudgetOperation[] {budgetOperation});

      // Set the budget to the campaign.
      Budget createdBudget = new Budget();
      createdBudget.setBudgetId(budgetReturnValue.getValue(0).getBudgetId());
      campaign.setBudget(createdBudget);

      // Set the campaign network options to Search and Search Network.
      NetworkSetting networkSetting = new NetworkSetting();
      networkSetting.setTargetGoogleSearch(true);
      networkSetting.setTargetSearchNetwork(true);
      networkSetting.setTargetContentNetwork(false);
      networkSetting.setTargetPartnerSearchNetwork(false);
      campaign.setNetworkSetting(networkSetting);

      // Set options that are not required.
      GeoTargetTypeSetting geoTarget = new GeoTargetTypeSetting();
      geoTarget.setPositiveGeoTargetType(GeoTargetTypeSettingPositiveGeoTargetType.DONT_CARE);
      KeywordMatchSetting keywordMatch = new KeywordMatchSetting();
      keywordMatch.setOptIn(Boolean.FALSE);

      campaign.setSettings(new Setting[] {geoTarget, keywordMatch});

      // Create operations.
      CampaignOperation operation = new CampaignOperation();
      operation.setOperand(campaign);
      operation.setOperator(Operator.ADD);

      CampaignOperation[] operations = new CampaignOperation[] {operation};

      // Add campaign.
      CampaignReturnValue result = campaignService.mutate(operations);

      // Display campaigns.
      if (result != null && result.getValue() != null) {
        for (Campaign campaignResult : result.getValue()) {
          System.out.println("Campaign with name \"" + campaignResult.getName() + "\" and id \""
View Full Code Here

      // Get AdWordsUser from "~/adwords.properties".
      AdWordsUser user = new AdWordsUser();

      // Get the validation CampaignService.
      CampaignServiceInterface campaignValidationService =
          user.getValidationService(AdWordsService.V201309.CAMPAIGN_SERVICE);

      // Create campaign.
      Campaign goodCampaign = new Campaign();
      goodCampaign.setName("Campaign #" + System.currentTimeMillis());
      goodCampaign.setStatus(CampaignStatus.PAUSED);

      // Create the bids.
      BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration();
      ManualCpmBiddingScheme manualCpm = new ManualCpmBiddingScheme();
      biddingConfig.setBiddingScheme(manualCpm);
      goodCampaign.setBiddingStrategyConfiguration(biddingConfig);

      // Create budget.
      Budget budget = new Budget();
      budget.setPeriod(BudgetBudgetPeriod.DAILY);
      budget.setAmount(new Money(null, 50000000L));
      budget.setDeliveryMethod(BudgetBudgetDeliveryMethod.STANDARD);
      goodCampaign.setBudget(budget);

      // Create operations.
      CampaignOperation operation = new CampaignOperation();
      operation.setOperand(goodCampaign);
      operation.setOperator(Operator.ADD);

      CampaignOperation[] operations = new CampaignOperation[] {operation};

      // Validate campaign add operation.
      CampaignReturnValue result = campaignValidationService.mutate(operations);

      // Display new campaigns, which should be none if the service was a
      // validation service.
      if (result != null) {
        for (Campaign campaignResult : result.getValue()) {
          System.out.println("New campaign with name \"" + campaignResult.getName()
              + "\" and id \"" + campaignResult.getId() + "\" was created.");
        }
      } else {
        System.out.println("No campaigns created.");
      }

      // Provide an invalid bidding strategy that will cause an exception
      // during validation.
      Campaign badCampaign = new Campaign();
      badCampaign.setName("Campaign #" + System.currentTimeMillis());
      badCampaign.setStatus(CampaignStatus.PAUSED);
      badCampaign.setBudget(budget);

      // Throws RequiredError.REQUIRED @ operations[0].operand.biddingStrategy.
      badCampaign.setBiddingStrategyConfiguration(null);

      // Create operations.
      operation = new CampaignOperation();
      operation.setOperand(badCampaign);
      operation.setOperator(Operator.ADD);

      operations = new CampaignOperation[] {operation};

      try {
        // Validate campaign add operation.
        result = campaignValidationService.mutate(operations);
      } catch (ApiException e) {
        System.err.println("Validation failed for reason \"" + e.getMessage1() + "\".");
      }
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

      // Get AdWordsUser from "~/adwords.properties".
      AdWordsUser user = new AdWordsUser();

      // Get the CampaignService.
      CampaignServiceInterface campaignService =
          user.getService(AdWordsService.V201309.CAMPAIGN_SERVICE);

      // Create campaign.
      Campaign campaign = new Campaign();
      campaign.setName("Interplanetary Cruise #" + System.currentTimeMillis());
      campaign.setStatus(CampaignStatus.PAUSED);

      // Create the bids.
      BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration();
      ManualCpmBiddingScheme manualCpm = new ManualCpmBiddingScheme();
      biddingConfig.setBiddingScheme(manualCpm);
      campaign.setBiddingStrategyConfiguration(biddingConfig);

      // Enable campaign for Real-time bidding.
      campaign.setSettings(new Setting[] {new RealTimeBiddingSetting(null, true)});

      // Create budget.
      Budget budget = new Budget();
      budget.setPeriod(BudgetBudgetPeriod.DAILY);
      budget.setAmount(new Money(null, 50000000L));
      budget.setDeliveryMethod(BudgetBudgetDeliveryMethod.STANDARD);
      campaign.setBudget(budget);

      // Create operations.
      CampaignOperation operation = new CampaignOperation();
      operation.setOperand(campaign);
      operation.setOperator(Operator.ADD);

      CampaignOperation[] operations = new CampaignOperation[] {operation};

      // Add campaign.
      CampaignReturnValue result = campaignService.mutate(operations);

      // Display campaigns.
      if (result != null && result.getValue() != null) {
        for (Campaign campaignResult : result.getValue()) {
          System.out.println("Campaign with name \"" + campaignResult.getName() + "\" and id \""
View Full Code Here

      // Get AdWordsUser from "~/adwords.properties".
      AdWordsUser user = new AdWordsUser();

      // Get the CampaignService.
      CampaignServiceInterface campaignService =
          user.getService(AdWordsService.V201309.CAMPAIGN_SERVICE);

      // Create campaign.
      Campaign campaign = new Campaign();
      campaign.setName("Interplanetary Cruise #" + System.currentTimeMillis());
      campaign.setStatus(CampaignStatus.PAUSED);

      // Create the bids.
      BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration();
      ManualCpmBiddingScheme manualCpm = new ManualCpmBiddingScheme();
      biddingConfig.setBiddingScheme(manualCpm);
      campaign.setBiddingStrategyConfiguration(biddingConfig);

      BudgetServiceInterface budgetService = user.getService(AdWordsService.V201309.BUDGET_SERVICE);

      // Create budget.
      Budget budget = new Budget();
      budget.setName("Interplanetary Budget #" + System.currentTimeMillis());
      budget.setPeriod(BudgetBudgetPeriod.DAILY);
      budget.setAmount(new Money(null, 50000000L));
      budget.setDeliveryMethod(BudgetBudgetDeliveryMethod.STANDARD);

      // Add budget.
      BudgetOperation budgetOperation = new BudgetOperation();
      budgetOperation.setOperand(budget);
      budgetOperation.setOperator(Operator.ADD);
      BudgetReturnValue budgetReturnValue =
          budgetService.mutate(new BudgetOperation[] {budgetOperation});

      // Set the budget to the campaign.
      Budget createdBudget = new Budget();
      createdBudget.setBudgetId(budgetReturnValue.getValue(0).getBudgetId());
      campaign.setBudget(createdBudget);

      // Set the campaign network options to Search and Search Network.
      NetworkSetting networkSetting = new NetworkSetting();
      networkSetting.setTargetContentNetwork(false);
      campaign.setNetworkSetting(networkSetting);

      // Set options that are not required.
      GeoTargetTypeSetting geoTarget = new GeoTargetTypeSetting();
      geoTarget.setPositiveGeoTargetType(GeoTargetTypeSettingPositiveGeoTargetType.DONT_CARE);
      KeywordMatchSetting keywordMatch = new KeywordMatchSetting();
      keywordMatch.setOptIn(Boolean.FALSE);

      campaign.setSettings(new Setting[] {geoTarget, keywordMatch});

      // Create operations.
      CampaignOperation operation = new CampaignOperation();
      operation.setOperand(campaign);
      operation.setOperator(Operator.ADD);

      CampaignOperation[] operations = new CampaignOperation[] {operation};

      // Add campaign.
      CampaignReturnValue result = campaignService.mutate(operations);

      // Display campaigns.
      if (result != null && result.getValue() != null) {
        for (Campaign campaignResult : result.getValue()) {
          System.out.println("Campaign with name \"" + campaignResult.getName() + "\" and id \""
View Full Code Here

TOP

Related Classes of com.google.api.adwords.v201306.cm.CampaignServiceInterface

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.