Package com.google.api.ads.adwords.jaxws.v201309.cm

Examples of com.google.api.ads.adwords.jaxws.v201309.cm.AdGroupCriterionServiceInterface


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

      // Get the AdGroupCriterionService.
      AdGroupCriterionServiceInterface adGroupCriterionService =
          user.getService(AdWordsService.V201306.ADGROUP_CRITERION_SERVICE);

      long adGroupId = Long.parseLong("INSERT_AD_GROUP_ID_HERE");

      // Create keyword.
      Keyword keyword = new Keyword();
      keyword.setText("mars cruise");
      keyword.setMatchType(KeywordMatchType.BROAD);

      // Create biddable ad group criterion.
      BiddableAdGroupCriterion keywordBiddableAdGroupCriterion = new BiddableAdGroupCriterion();
      keywordBiddableAdGroupCriterion.setAdGroupId(adGroupId);
      keywordBiddableAdGroupCriterion.setCriterion(keyword);

      // Create placement.
      Placement placement = new Placement();
      placement.setUrl("http://mars.google.com");

      // Create biddable ad group criterion for placement.
      BiddableAdGroupCriterion placementBiddableAdGroupCriterion = new BiddableAdGroupCriterion();
      placementBiddableAdGroupCriterion.setAdGroupId(adGroupId);
      placementBiddableAdGroupCriterion.setCriterion(placement);

      // Create operations.
      AdGroupCriterionOperation keywordAdGroupCriterionOperation = new AdGroupCriterionOperation();
      keywordAdGroupCriterionOperation.setOperand(keywordBiddableAdGroupCriterion);
      keywordAdGroupCriterionOperation.setOperator(Operator.ADD);

      AdGroupCriterionOperation placementAdGroupCriterionOperation =
          new AdGroupCriterionOperation();
      placementAdGroupCriterionOperation.setOperand(placementBiddableAdGroupCriterion);
      placementAdGroupCriterionOperation.setOperator(Operator.ADD);

      AdGroupCriterionOperation[] operations =
          new AdGroupCriterionOperation[] {keywordAdGroupCriterionOperation,
              placementAdGroupCriterionOperation};

      // Add ad group criteria.
      AdGroupCriterionReturnValue result = adGroupCriterionService.mutate(operations);

      // Display ad group criteria.
      if (result != null && result.getValue() != null) {
        for (AdGroupCriterion adGroupCriterionResult : result.getValue()) {
          System.out.println("Ad group criterion with ad group id \""
View Full Code Here


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

      // Get the AdGroupCriterionService.
      AdGroupCriterionServiceInterface adGroupCriterionService =
          user.getService(AdWordsService.V201306.ADGROUP_CRITERION_SERVICE);

      long adGroupId = Long.parseLong("INSERT_AD_GROUP_ID_HERE");

      // Create biddable ad group criterion for gender
      Gender genderTarget = new Gender();
      genderTarget.setId(ID_FOR_MALE);
      BiddableAdGroupCriterion genderBiddableAdGroupCriterion = new BiddableAdGroupCriterion();
      genderBiddableAdGroupCriterion.setAdGroupId(adGroupId);
      genderBiddableAdGroupCriterion.setCriterion(genderTarget);

      // Create negative ad group criterion for age range
      AgeRange ageRangeNegative = new AgeRange();
      ageRangeNegative.setId(ID_FOR_18_TO_24);
      NegativeAdGroupCriterion ageRangeNegativeAdGroupCriterion = new NegativeAdGroupCriterion();
      ageRangeNegativeAdGroupCriterion.setAdGroupId(adGroupId);
      ageRangeNegativeAdGroupCriterion.setCriterion(ageRangeNegative);

      // Create operations.
      AdGroupCriterionOperation genderBiddableAdGroupCriterionOperation =
          new AdGroupCriterionOperation();
      genderBiddableAdGroupCriterionOperation.setOperand(genderBiddableAdGroupCriterion);
      genderBiddableAdGroupCriterionOperation.setOperator(Operator.ADD);

      AdGroupCriterionOperation ageRangeNegativeAdGroupCriterionOperation =
          new AdGroupCriterionOperation();
      ageRangeNegativeAdGroupCriterionOperation.setOperand(ageRangeNegativeAdGroupCriterion);
      ageRangeNegativeAdGroupCriterionOperation.setOperator(Operator.ADD);

      AdGroupCriterionOperation[] operations = new AdGroupCriterionOperation[] {
          genderBiddableAdGroupCriterionOperation, ageRangeNegativeAdGroupCriterionOperation};

      // Add ad group criteria.
      AdGroupCriterionReturnValue result = adGroupCriterionService.mutate(operations);

      // Display ad group criteria.
      if (result != null && result.getValue() != null) {
        for (AdGroupCriterion adGroupCriterionResult : result.getValue()) {
          System.out.println("Ad group criterion with ad group id \""
View Full Code Here

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

      // Get the AdGroupCriterionService.
      AdGroupCriterionServiceInterface adGroupCriterionService =
          user.getService(AdWordsService.V201306.ADGROUP_CRITERION_SERVICE);

      long adGroupId = Long.parseLong("INSERT_AD_GROUP_ID_HERE");
      long criterionId = Long.parseLong("INSERT_CRITERION_ID_HERE");

      // Create ad group criterion with updated bid.
      Criterion criterion = new Criterion();
      criterion.setId(criterionId);

      BiddableAdGroupCriterion biddableAdGroupCriterion = new BiddableAdGroupCriterion();
      biddableAdGroupCriterion.setAdGroupId(adGroupId);
      biddableAdGroupCriterion.setCriterion(criterion);

      BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration();
      CpcBid cpcBid = new CpcBid();
      cpcBid.setBid(new Money(null, 1000000L));
      biddingConfig.setBids(new Bids[] {cpcBid});
      biddableAdGroupCriterion.setBiddingStrategyConfiguration(biddingConfig);

      // Create operations.
      AdGroupCriterionOperation operation = new AdGroupCriterionOperation();
      operation.setOperand(biddableAdGroupCriterion);
      operation.setOperator(Operator.SET);

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

      // Update ad group criteria.
      AdGroupCriterionReturnValue result = adGroupCriterionService.mutate(operations);

      // Display ad group criteria.
      if (result != null && result.getValue() != null) {
        for (AdGroupCriterion adGroupCriterionResult : result.getValue()) {
          if (adGroupCriterionResult instanceof BiddableAdGroupCriterion) {
View Full Code Here

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

      // Get the AdGroupCriterionService.
      AdGroupCriterionServiceInterface adGroupCriterionService =
          user.getService(AdWordsService.V201306.ADGROUP_CRITERION_SERVICE);

      long adGroupId = Long.parseLong("INSERT_AD_GROUP_ID_HERE");

      // Create placement.
      Placement placement = new Placement();
      placement.setUrl("http://mars.google.com");

      // Create biddable ad group criterion for placement.
      BiddableAdGroupCriterion placementBiddableAdGroupCriterion = new BiddableAdGroupCriterion();
      placementBiddableAdGroupCriterion.setAdGroupId(adGroupId);
      placementBiddableAdGroupCriterion.setCriterion(placement);

      // Create operation.
      AdGroupCriterionOperation placementAdGroupCriterionOperation =
          new AdGroupCriterionOperation();
      placementAdGroupCriterionOperation.setOperand(placementBiddableAdGroupCriterion);
      placementAdGroupCriterionOperation.setOperator(Operator.ADD);

      AdGroupCriterionOperation[] operations =
          new AdGroupCriterionOperation[] {placementAdGroupCriterionOperation};

      // Add ad group criteria.
      AdGroupCriterionReturnValue result = adGroupCriterionService.mutate(operations);

      // Display ad group criteria.
      if (result != null && result.getValue() != null) {
        for (AdGroupCriterion adGroupCriterionResult : result.getValue()) {
          System.out.println("Ad group criterion with ad group id \""
View Full Code Here

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

      // Get the AdGroupCriterionService.
      AdGroupCriterionServiceInterface adGroupCriterionService =
          user.getService(AdWordsService.V201306.ADGROUP_CRITERION_SERVICE);

      long adGroupId = Long.parseLong("INSERT_AD_GROUP_ID_HERE");
      long criterionId = Long.parseLong("INSERT_CRITERION_ID_HERE");

      // Create ad group criterion with updated bid.
      Criterion criterion = new Criterion();
      criterion.setId(criterionId);

      BiddableAdGroupCriterion biddableAdGroupCriterion = new BiddableAdGroupCriterion();
      biddableAdGroupCriterion.setAdGroupId(adGroupId);
      biddableAdGroupCriterion.setCriterion(criterion);

      // Create operations.
      AdGroupCriterionOperation operation = new AdGroupCriterionOperation();
      operation.setOperand(biddableAdGroupCriterion);
      operation.setOperator(Operator.SET);

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

      // Update ad group criteria.
      AdGroupCriterionReturnValue result = adGroupCriterionService.mutate(operations);

      // Display ad group criteria.
      if (result != null && result.getValue() != null) {
        for (AdGroupCriterion adGroupCriterionResult : result.getValue()) {
          if (adGroupCriterionResult instanceof BiddableAdGroupCriterion) {
View Full Code Here

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

      // Get the AdGroupCriterionService.
      AdGroupCriterionServiceInterface adGroupCriterionService =
          user.getService(AdWordsService.V201309.ADGROUP_CRITERION_SERVICE);

      Long adGroupId = Long.parseLong("INSERT_AD_GROUP_ID_HERE");

      String query = String.format(
          "SELECT Id, AdGroupId, Status WHERE AdGroupId = %d AND Status = ACTIVE ORDER BY Id ",
          adGroupId);

      // Get all active ad group criteria.
      AdGroupCriterionPage page = adGroupCriterionService.query(query);

      // Display ad group criteria.
      if (page.getEntries() != null && page.getEntries().length > 0) {
        for (AdGroupCriterion adGroupCriterion : page.getEntries()) {
          if (adGroupCriterion instanceof BiddableAdGroupCriterion) {
View Full Code Here

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

      // Get the AdGroupCriterionService.
      AdGroupCriterionServiceInterface adGroupCriterionService =
          user.getService(AdWordsService.V201309.ADGROUP_CRITERION_SERVICE);

      Long adGroupId = Long.parseLong("INSERT_AD_GROUP_ID_HERE");

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

      // Create predicates.
      Predicate statusPredicate =
          new Predicate("Status", PredicateOperator.IN, new String[] {"ACTIVE"});
      Predicate adGroupIdPredicate =
          new Predicate("AdGroupId", PredicateOperator.IN, new String[] {adGroupId.toString()});
      selector.setPredicates(new Predicate[] {statusPredicate, adGroupIdPredicate});

      // Get all active ad group criteria.
      AdGroupCriterionPage page = adGroupCriterionService.get(selector);

      // Display ad group criteria.
      if (page.getEntries() != null && page.getEntries().length > 0) {
        for (AdGroupCriterion adGroupCriterion : page.getEntries()) {
          if (adGroupCriterion instanceof BiddableAdGroupCriterion) {
View Full Code Here

      // Get the AdGroupService.
      AdGroupServiceInterface adGroupService =
          user.getService(AdWordsService.V201309.ADGROUP_SERVICE);

      // Get the AdGroupCriterionService.
      AdGroupCriterionServiceInterface adGroupCriterionService =
          user.getService(AdWordsService.V201309.ADGROUP_CRITERION_SERVICE);

      // Replace with valid values of your account.
      long campaignId = Long.parseLong("INSERT_CAMPAIGN_ID_HERE");
      long adGroupId = Long.parseLong("INSERT_AD_GROUP_ID_HERE");
      long criterionId = Long.parseLong("INSERT_CRITERION_ID_HERE");

      // Create experiment.
      Experiment experiment = new Experiment();
      experiment.setCampaignId(campaignId);
      experiment.setName("Interplanetary Experiment #" + System.currentTimeMillis());
      experiment.setQueryPercentage(10);
      experiment.setStartDateTime(new SimpleDateFormat("yyyyMMdd HHmmss Z").format(new Date()));

      // Create operation.
      ExperimentOperation experimentOperation = new ExperimentOperation();
      experimentOperation.setOperand(experiment);
      experimentOperation.setOperator(Operator.ADD);

      // Add experiment.
      ExperimentReturnValue result =
          experimentService.mutate(new ExperimentOperation[]{experimentOperation});

      if (result.getValue() != null) {
        for(Experiment experimentResult : result.getValue()) {
          System.out.println("Experiment with name \"" + experimentResult.getName()
              + "\" and id \"" + experimentResult.getId() + "\" was added.");
        }
      } else {
        System.out.println ("No experiments were added.");
        return;
      }

      Long experimentId = result.getValue()[0].getId();

      // Set ad group for the experiment.
      AdGroup adGroup = new AdGroup();
      adGroup.setId(adGroupId);

      // Create experiment bid multiplier rule that will modify ad group bid for
      // the experiment.
      ManualCPCAdGroupExperimentBidMultipliers adGroupExperimentBidMultipliers =
          new ManualCPCAdGroupExperimentBidMultipliers();
      adGroupExperimentBidMultipliers.setMaxCpcMultiplier(new BidMultiplier(1.5, null));

      // Set experiment data to the ad group.
      AdGroupExperimentData adGroupExperimentData = new AdGroupExperimentData();
      adGroupExperimentData.setExperimentId(experimentId);
      adGroupExperimentData.setExperimentDeltaStatus(ExperimentDeltaStatus.MODIFIED);
      adGroupExperimentData.setExperimentBidMultipliers(adGroupExperimentBidMultipliers);
      adGroup.setExperimentData(adGroupExperimentData);

      // Create operation.
      AdGroupOperation adGroupOperation = new AdGroupOperation();
      adGroupOperation.setOperand(adGroup);
      adGroupOperation.setOperator(Operator.SET);

      // Update ad group.
      adGroup = adGroupService.mutate(new AdGroupOperation[]{adGroupOperation}).getValue()[0];

      System.out.println("Ad group with name \"" + adGroup.getName() + "\" and id \""
          + adGroup.getId() + "\" was updated for the experiment.");

      // Set ad group criterion for the experiment.
      BiddableAdGroupCriterion adGroupCriterion = new BiddableAdGroupCriterion();
      adGroupCriterion.setCriterion(new Criterion(criterionId, null, null));
      adGroupCriterion.setAdGroupId(adGroupId);

      // Create experiment bid multiplier rule that will modify ad group bid for
      // the experiment.
      ManualCPCAdGroupCriterionExperimentBidMultiplier adGroupCriterionExperimentBidMultiplier =
          new ManualCPCAdGroupCriterionExperimentBidMultiplier();
      adGroupCriterionExperimentBidMultiplier.setMaxCpcMultiplier(new BidMultiplier(1.5, null));

      // Set experiment data to the ad group.
      BiddableAdGroupCriterionExperimentData adGroupCriterionExperimentData =
          new BiddableAdGroupCriterionExperimentData();
      adGroupCriterionExperimentData.setExperimentId(experimentId);
      adGroupCriterionExperimentData.setExperimentDeltaStatus(ExperimentDeltaStatus.MODIFIED);
      adGroupCriterionExperimentData
          .setExperimentBidMultiplier(adGroupCriterionExperimentBidMultiplier);
      adGroupCriterion.setExperimentData(adGroupCriterionExperimentData);

      // Create operation.
      AdGroupCriterionOperation adGroupCriterionOperation = new AdGroupCriterionOperation();
      adGroupCriterionOperation.setOperand(adGroupCriterion);
      adGroupCriterionOperation.setOperator(Operator.SET);

      // Update ad group criterion.
      adGroupCriterion =
          (BiddableAdGroupCriterion) adGroupCriterionService.mutate(
              new AdGroupCriterionOperation[] {adGroupCriterionOperation}).getValue()[0];

      System.out.println("Ad group criterion with ad group id \"" + adGroupCriterion.getAdGroupId()
          + "\" and criterion id \"" + adGroupCriterion.getCriterion().getId()
          + "\" was updated for the experiment.");
View Full Code Here

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

      // Get the AdGroupCriterionService.
      AdGroupCriterionServiceInterface adGroupCriterionService =
          user.getService(AdWordsService.V201309.ADGROUP_CRITERION_SERVICE);

      long adGroupId = Long.parseLong("INSERT_AD_GROUP_ID_HERE");
      long criterionId = Long.parseLong("INSERT_CRITERION_ID_HERE");

      // Create base class criterion to avoid setting keyword and placement specific
      // fields.
      Criterion criterion = new Criterion();
      criterion.setId(criterionId);

      // Create ad group criterion.
      AdGroupCriterion adGroupCriterion = new AdGroupCriterion();
      adGroupCriterion.setAdGroupId(adGroupId);
      adGroupCriterion.setCriterion(criterion);

      // Create operations.
      AdGroupCriterionOperation operation = new AdGroupCriterionOperation();
      operation.setOperand(adGroupCriterion);
      operation.setOperator(Operator.REMOVE);

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

      // Delete ad group criteria.
      AdGroupCriterionReturnValue result = adGroupCriterionService.mutate(operations);

      // Display ad group criteria.
      if (result != null && result.getValue() != null) {
        for (AdGroupCriterion adGroupCriterionResult : result.getValue()) {
          System.out.println("Ad group criterion with ad group id \""
View Full Code Here

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

      // Get the AdGroupCriterionService.
      AdGroupCriterionServiceInterface adGroupCriterionService =
          user.getService(AdWordsService.V201309.ADGROUP_CRITERION_SERVICE);

      Long adGroupId = Long.parseLong("INSERT_AD_GROUP_ID_HERE");

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

      // Create predicates.
      Predicate adGroupIdPredicate =
          new Predicate("AdGroupId", PredicateOperator.IN, new String[] {adGroupId.toString()});
      selector.setPredicates(new Predicate[] {adGroupIdPredicate});

      // Get all ad group criteria.
      AdGroupCriterionPage page = adGroupCriterionService.get(selector);

      // Display ad group criteria.
      if (page.getEntries() != null && page.getEntries().length > 0) {
        for (AdGroupCriterion adGroupCriterion : page.getEntries()) {
          System.out.println("Ad group criterion with ad group id \""
View Full Code Here

TOP

Related Classes of com.google.api.ads.adwords.jaxws.v201309.cm.AdGroupCriterionServiceInterface

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.