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

Examples of com.google.api.ads.adwords.axis.v201306.cm.AdGroupCriterionOperation


      createSiteLinksFeedMapping(feedMappingService, siteLinksFeed);
    }

    for (long campaignId : campaignIds) {
      // Get legacy sitelinks for the campaign.
      CampaignAdExtension extension =
          getLegacySitelinksForCampaign(campaignExtensionService, campaignId);
      if (extension != null) {
        // Get the sitelinks.
        Sitelink[] legacySitelinks =
            ((SitelinksExtension) extension.getAdExtension()).getSitelinks();

        // Add the sitelinks to the feed.
        List<Long> siteLinkFeedItemIds =
            createSiteLinkFeedItems(feedItemService, siteLinksFeed, legacySitelinks);
View Full Code Here


   */
  private static void deleteLegacySitelinks(
      CampaignAdExtensionServiceInterface campaignExtensionService,
      CampaignAdExtension extensionToDelete) throws Exception {

    CampaignAdExtensionOperation operation = new CampaignAdExtensionOperation();
    operation.setOperator(Operator.REMOVE);
    operation.setOperand(extensionToDelete);

    campaignExtensionService.mutate(new CampaignAdExtensionOperation[] {operation});
  }
View Full Code Here

    typePredicate.setField("AdExtensionType");
    typePredicate.setValues(new String[] {"SITELINKS_EXTENSION"});

    selector.setPredicates(new Predicate[] {campaignPredicate, statusPredicate, typePredicate});

    CampaignAdExtensionPage page = campaignExtensionService.get(selector);
    if (page.getEntries() != null && page.getEntries().length > 0) {
      return page.getEntries()[0];
    } else {
      return null;
    }
  }
View Full Code Here

  }

  public static void runExample(AdWordsServices adWordsServices, AdWordsSession session,
      long[] campaignIds) throws Exception {
    // Get the CampaignAdExtensionService.
    CampaignAdExtensionServiceInterface campaignExtensionService =
        adWordsServices.get(session, CampaignAdExtensionServiceInterface.class);
    // Get the FeedMappingService.
    FeedMappingServiceInterface feedMappingService =
        adWordsServices.get(session, FeedMappingServiceInterface.class);
    // Get the FeedService.
View Full Code Here

        "LanguageName", "LocationName", "KeywordText"});
    selector.setPredicates(new Predicate[] {new Predicate("CriteriaType", PredicateOperator.IN,
        new String[] {"KEYWORD", "LANGUAGE", "LOCATION", "PLATFORM"})});
    selector.setPaging(new Paging(offset, PAGE_SIZE));

    CampaignCriterionPage page = null;
    do {
      page = campaignCriterionService.get(selector);

      if (page.getEntries() != null) {
        // Display campaigns.
        for (CampaignCriterion campaignCriterion : page.getEntries()) {
          System.out.printf("Campaign criterion with campaign id '%s', criterion id '%s', "
              + "and type '%s' was found.\n", campaignCriterion.getCampaignId(), campaignCriterion
              .getCriterion().getId(), campaignCriterion.getCriterion().getCriterionType());
        }
        Thread.sleep(1000);
      } else {
        System.out.println("No campaign criteria were found.");
      }
      offset += PAGE_SIZE;
      selector.getPaging().setStartIndex(offset);
    } while (offset < page.getTotalNumEntries());
  }
View Full Code Here

  }

  public static void runExample(
      AdWordsServices adWordsServices, AdWordsSession session) throws Exception {
    // Get the CampaignService.
    CampaignCriterionServiceInterface campaignCriterionService =
        adWordsServices.get(session, CampaignCriterionServiceInterface.class);

    int offset = 0;

    // Create selector.
    Selector selector = new Selector();
    selector.setFields(new String[] {"CampaignId", "Id", "CriteriaType", "PlatformName",
        "LanguageName", "LocationName", "KeywordText"});
    selector.setPredicates(new Predicate[] {new Predicate("CriteriaType", PredicateOperator.IN,
        new String[] {"KEYWORD", "LANGUAGE", "LOCATION", "PLATFORM"})});
    selector.setPaging(new Paging(offset, PAGE_SIZE));

    CampaignCriterionPage page = null;
    do {
      page = campaignCriterionService.get(selector);

      if (page.getEntries() != null) {
        // Display campaigns.
        for (CampaignCriterion campaignCriterion : page.getEntries()) {
          System.out.printf("Campaign criterion with campaign id '%s', criterion id '%s', "
View Full Code Here

    }
    function.setRhsOperand(operands.toArray(new FunctionArgumentOperand[operands.size()]));

    // Create upgraded sitelinks for the campaign. Use the sitelinks feed we
    // created, and restrict feed items by matching function.
    CampaignFeed campaignFeed = new CampaignFeed();
    campaignFeed.setFeedId(siteLinksFeed.siteLinksFeedId);
    campaignFeed.setCampaignId(campaignId);
    campaignFeed.setMatchingFunction(function);
    campaignFeed.setPlaceholderTypes(new int[] {PLACEHOLDER_SITELINKS});

    CampaignFeedOperation operation = new CampaignFeedOperation();
    operation.setOperand(campaignFeed);
    operation.setOperator(Operator.ADD);
    campaignFeedService.mutate(new CampaignFeedOperation[] {operation});
View Full Code Here

    TrafficEstimatorServiceInterface trafficEstimatorService =
        adWordsServices.get(session, TrafficEstimatorServiceInterface.class);

    // 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.printf("Results for the keyword with text \'%s\' and match type \'%s\':%n",
            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

    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

    // Language setting (optional).
    // The ID can be found in the documentation:
    //   https://developers.google.com/adwords/api/docs/appendix/languagecodes
    // Note: As of v201302, only a single language parameter is allowed.
    LanguageSearchParameter languageParameter = new LanguageSearchParameter();
    Language english = new Language();
    english.setId(1000L);
    languageParameter.setLanguages(new Language[] {english});

    selector.setSearchParameters(
        new SearchParameter[] {relatedToQuerySearchParameter, languageParameter});
View Full Code Here

TOP

Related Classes of com.google.api.ads.adwords.axis.v201306.cm.AdGroupCriterionOperation

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.