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

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


      TrafficEstimatorServiceInterface trafficEstimatorService =
          user.getService(AdWordsService.V201306.TRAFFIC_ESTIMATOR_SERVICE);

      // Create keywords. Up to 2000 keywords can be passed in a single request.
      List<Keyword> keywords = new ArrayList<Keyword>();
      keywords.add(new Keyword(null, null, null, "mars cruise", KeywordMatchType.BROAD));
      keywords.add(new Keyword(null, null, null, "cheap cruise", KeywordMatchType.PHRASE));
      keywords.add(new Keyword(null, null, null, "cruise", KeywordMatchType.EXACT));

      // Create a keyword estimate request for each keyword.
      List<KeywordEstimateRequest> keywordEstimateRequests =
          new ArrayList<KeywordEstimateRequest>();
      for (Keyword keyword : keywords) {
        KeywordEstimateRequest keywordEstimateRequest = new KeywordEstimateRequest();
        keywordEstimateRequest.setKeyword(keyword);
        keywordEstimateRequests.add(keywordEstimateRequest);
      }

      // Add a negative keyword to the traffic estimate.
      KeywordEstimateRequest negativeKeywordEstimateRequest = new KeywordEstimateRequest();
      negativeKeywordEstimateRequest.setKeyword(new Keyword(null, null, null, "hiking tour",
          KeywordMatchType.BROAD));
      negativeKeywordEstimateRequest.setIsNegative(true);
      keywordEstimateRequests.add(negativeKeywordEstimateRequest);

      // Create ad group estimate requests.
      List<AdGroupEstimateRequest> adGroupEstimateRequests =
          new ArrayList<AdGroupEstimateRequest>();
      AdGroupEstimateRequest adGroupEstimateRequest = new AdGroupEstimateRequest();
      adGroupEstimateRequest.setKeywordEstimateRequests(
          keywordEstimateRequests.toArray(new KeywordEstimateRequest[]{}));
      adGroupEstimateRequest.setMaxCpc(new Money(null, 1000000L));
      adGroupEstimateRequests.add(adGroupEstimateRequest);

      // Create campaign estimate requests.
      List<CampaignEstimateRequest> campaignEstimateRequests =
        new ArrayList<CampaignEstimateRequest>();
      CampaignEstimateRequest campaignEstimateRequest = new CampaignEstimateRequest();
      campaignEstimateRequest.setAdGroupEstimateRequests(
          adGroupEstimateRequests.toArray(new AdGroupEstimateRequest[]{}));
      Location unitedStates = new Location();
      unitedStates.setId(2840L);
      Language english = new Language();
      english.setId(1000L);
      campaignEstimateRequest.setCriteria(new Criterion[]{unitedStates, english});
      campaignEstimateRequests.add(campaignEstimateRequest);

      // Create selector.
      TrafficEstimatorSelector selector = new TrafficEstimatorSelector();
      selector.setCampaignEstimateRequests(
          campaignEstimateRequests.toArray(new CampaignEstimateRequest[]{}));

      // Get traffic estimates.
      TrafficEstimatorResult result = trafficEstimatorService.get(selector);

      // Display traffic estimates.
      if (result != null && result.getCampaignEstimates() != null) {
        KeywordEstimate[] keywordEstimates =
            result.getCampaignEstimates()[0].getAdGroupEstimates()[0].getKeywordEstimates();
        for (int i = 0; i < keywordEstimates.length; i++) {
          Keyword keyword = keywordEstimateRequests.get(i).getKeyword();
          KeywordEstimate keywordEstimate = keywordEstimates[i];
          if (Boolean.TRUE.equals(keywordEstimateRequests.get(i).getIsNegative())) {
            continue;
          }

          // Find the mean of the min and max values.
          double meanAverageCpc = (keywordEstimate.getMin().getAverageCpc().getMicroAmount()
              + keywordEstimate.getMax().getAverageCpc().getMicroAmount()) / 2.0;
          double meanAveragePosition = (keywordEstimate.getMin().getAveragePosition()
              + keywordEstimate.getMax().getAveragePosition()) / 2.0;
          double meanClicks = (keywordEstimate.getMin().getClicksPerDay()
              + keywordEstimate.getMax().getClicksPerDay()) / 2.0;
          double meanTotalCost = (keywordEstimate.getMin().getTotalCost().getMicroAmount()
              + keywordEstimate.getMax().getTotalCost().getMicroAmount()) / 2.0;

          System.out.println(String.format(
              "Results for the keyword with text '%s' and match type '%s':",
              keyword.getText(), keyword.getMatchType()));
          System.out.printf("\tEstimated average CPC: %.2f\n", meanAverageCpc);
          System.out.printf("\tEstimated ad position: %.2f\n", meanAveragePosition);
          System.out.printf("\tEstimated daily clicks: %.2f\n", meanClicks);
          System.out.printf("\tEstimated daily cost: %.2f\n\n", meanTotalCost);
        }
View Full Code Here


        // Create Keyword.
        String text = String.format("mars%d", i);
        if (r.nextInt() % 10 == 0) {
          text = text + "!!!";
        }
        Keyword keyword = new Keyword();
        keyword.setText(text);
        keyword.setMatchType(KeywordMatchType.BROAD);
        // Create BiddableAdGroupCriterion.
        BiddableAdGroupCriterion bagc = new BiddableAdGroupCriterion();
        bagc.setAdGroupId(adGroupId);
        bagc.setCriterion(keyword);
        // Create AdGroupCriterionOperation.
View Full Code Here

          user.getService(AdWordsService.V201306.CAMPAIGN_CRITERION_SERVICE);

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

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

      // Create negative campaign criterion.
      NegativeCampaignCriterion negativeCampaignCriterion = new NegativeCampaignCriterion();
      negativeCampaignCriterion.setCampaignId(campaignId);
      negativeCampaignCriterion.setCriterion(keyword);
View Full Code Here

      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);
View Full Code Here

      CampaignEstimateRequest campaignEstimateRequest = new CampaignEstimateRequest();
      campaignEstimateRequest.setAdGroupEstimateRequests(
          adGroupEstimateRequests.toArray(new AdGroupEstimateRequest[]{}));
      Location unitedStates = new Location();
      unitedStates.setId(2840L);
      Language english = new Language();
      english.setId(1000L);
      campaignEstimateRequest.setCriteria(new Criterion[]{unitedStates, english});
      campaignEstimateRequests.add(campaignEstimateRequest);

      // Create selector.
      TrafficEstimatorSelector selector = new TrafficEstimatorSelector();
View Full Code Here

      List<CampaignEstimateRequest> campaignEstimateRequests =
        new ArrayList<CampaignEstimateRequest>();
      CampaignEstimateRequest campaignEstimateRequest = new CampaignEstimateRequest();
      campaignEstimateRequest.setAdGroupEstimateRequests(
          adGroupEstimateRequests.toArray(new AdGroupEstimateRequest[]{}));
      Location unitedStates = new Location();
      unitedStates.setId(2840L);
      Language english = new Language();
      english.setId(1000L);
      campaignEstimateRequest.setCriteria(new Criterion[]{unitedStates, english});
      campaignEstimateRequests.add(campaignEstimateRequest);
View Full Code Here

      // 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();
View Full Code Here

      Predicate typePredicate =
          new Predicate("Type", PredicateOperator.IN, new String[] {"VIDEO"});
      selector.setPredicates(new Predicate[] {typePredicate});

      // Get all videos.
      MediaPage page = mediaService.get(selector);

      // Display videos.
      if (page.getEntries() != null) {
        for (Media video : page.getEntries()) {
          System.out.println("Video with id '" + video.getMediaId()
              + "' and name '" + video.getName() + "' was found.");
        }
      } else {
        System.out.println("No videos were found.");
View Full Code Here

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

      // Get the MediaService.
      MediaServiceInterface mediaService =
          user.getService(AdWordsService.V201306.MEDIA_SERVICE);

      // Create image.
      Image image = new Image();
      image.setData(ImageUtils.getImageDataFromUrl("http://goo.gl/HJM3L"));
      image.setType(MediaMediaType.IMAGE);

      Media[] media = new Media[] {image};

      // Upload image.
      Media[] result = mediaService.upload(media);

      // Display images.
      if (result != null) {
        image = (Image) result[0];
        Map<MediaSize, Dimensions> dimensions = MapUtils.toMap(image.getDimensions());
View Full Code Here

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

      // Get the MediaService.
      MediaServiceInterface mediaService =
          user.getService(AdWordsService.V201306.MEDIA_SERVICE);

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

      // Create predicates.
      Predicate typePredicate =
          new Predicate("Type", PredicateOperator.IN, new String[] {"VIDEO"});
      selector.setPredicates(new Predicate[] {typePredicate});

      // Get all videos.
      MediaPage page = mediaService.get(selector);

      // Display videos.
      if (page.getEntries() != null) {
        for (Media video : page.getEntries()) {
          System.out.println("Video with id '" + video.getMediaId()
View Full Code Here

TOP

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

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.