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

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


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


      selector.setFields(new String[] {"AdGroupId", "LandscapeType", "LandscapeCurrent",
          "StartDate", "EndDate", "Bid", "LocalClicks", "LocalCost", "MarginalCpc",
          "LocalImpressions"});

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

      // Get bid landscape for ad group criteria.
      AdGroupBidLandscapePage page = dataService.getAdGroupBidLandscape(selector);
View Full Code Here

          user.getService(AdWordsService.V201306.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.
View Full Code Here

          user.getService(AdWordsService.V201306.DATA_SERVICE);

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

      // Create selector.
      Selector selector = new Selector();
      selector.setFields(new String[] {"AdGroupId", "LandscapeType", "LandscapeCurrent",
          "StartDate", "EndDate", "Bid", "LocalClicks", "LocalCost", "MarginalCpc",
          "LocalImpressions"});

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

      // Get bid landscape for ad group criteria.
      AdGroupBidLandscapePage page = dataService.getAdGroupBidLandscape(selector);

      // Display bid landscapes.
View Full Code Here

      // this job can be processed.
      BulkMutateJobPolicy policy = new BulkMutateJobPolicy();
      policy.setPrerequisiteJobIds(new long[] {});

      // Call mutate to create a new job.
      SimpleMutateJob response =
          mutateJobService.mutate(operations.toArray(new Operation[operations.size()]), policy);

      long jobId = response.getId();
      System.out.printf("Job with ID %d was successfully created.\n", jobId);

      // Create selector to retrieve job status and wait for it to complete.
      BulkMutateJobSelector selector = new BulkMutateJobSelector();
      selector.setJobIds(new long[] {jobId});

      // Poll for job status until it's finished.
      System.out.println("Retrieving job status...");
      SimpleMutateJob jobStatusResponse = null;
      BasicJobStatus status = null;
      for (int i = 0; i < RETRIES_COUNT; i++) {
        Job[] jobs = mutateJobService.get(selector);
        jobStatusResponse = (SimpleMutateJob) jobs[0];
        status = jobStatusResponse.getStatus();
        if (status == BasicJobStatus.COMPLETED || status == BasicJobStatus.FAILED) {
          break;
        }
        System.out.printf("[%d] Current status is '%s', waiting %d seconds to retry...\n", i,
            status.toString(), RETRY_INTERVAL);
        Thread.sleep(RETRY_INTERVAL * 1000);
      }

      // Handle unsuccessful results.
      if (status == BasicJobStatus.FAILED) {
        throw new IllegalStateException("Job failed with reason: "
            + jobStatusResponse.getFailureReason());
      }
      if (status == BasicJobStatus.PENDING || status == BasicJobStatus.PROCESSING) {
        throw new IllegalAccessException("Job did not complete within "
            + ((RETRIES_COUNT - 1) * RETRY_INTERVAL) + " seconds.");
      }
View Full Code Here

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

      // Create text ad that violates an exemptable policy. This ad will only
      // trigger an error in the production environment.
      TextAd exemptableTextAd = new TextAd();
      exemptableTextAd.setHeadline("Mars " + System.currentTimeMillis() + "!!!");
      exemptableTextAd.setDescription1("Visit the Red Planet in style.");
      exemptableTextAd.setDescription2("Low-gravity fun for everyone!");
      exemptableTextAd.setDisplayUrl("www.example.com");
      exemptableTextAd.setUrl("http://www.example.com/");

      // Create ad group ad.
      AdGroupAd exemptableAdGroupAd = new AdGroupAd();
      exemptableAdGroupAd.setAdGroupId(adGroupId);
      exemptableAdGroupAd.setAd(exemptableTextAd);

      // Create operations.
      AdGroupAdOperation exemptableOperation = new AdGroupAdOperation();
      exemptableOperation.setOperand(exemptableAdGroupAd);
      exemptableOperation.setOperator(Operator.ADD);

      // Create text ad that violates an non-exemptable policy.
      TextAd nonExemptableTextAd = new TextAd();
      nonExemptableTextAd.setHeadline("Mars Cruise with too long of a headline.");
      nonExemptableTextAd.setDescription1("Visit the Red Planet in style.");
      nonExemptableTextAd.setDescription2("Low-gravity fun for everyone.");
      nonExemptableTextAd.setDisplayUrl("www.example.com");
      nonExemptableTextAd.setUrl("http://www.example.com/");

      // Create ad group ad.
      AdGroupAd nonExemptableAdGroupAd = new AdGroupAd();
      nonExemptableAdGroupAd.setAdGroupId(adGroupId);
      nonExemptableAdGroupAd.setAd(nonExemptableTextAd);
View Full Code Here

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

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

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

    FeedAttribute urlAttribute = new FeedAttribute();
    urlAttribute.setType(FeedAttributeType.URL);
    urlAttribute.setName("Link URL");

    // Create the feed.
    Feed siteLinksFeed = new Feed();
    siteLinksFeed.setName("Feed For Site Links");
    siteLinksFeed.setAttributes(new FeedAttribute[] {textAttribute, urlAttribute});
    siteLinksFeed.setOrigin(FeedOrigin.USER);

    // Create operation.
    FeedOperation operation = new FeedOperation();
    operation.setOperand(siteLinksFeed);
    operation.setOperator(Operator.ADD);

    // Add the feed.
    FeedReturnValue result = feedService.mutate(new FeedOperation[] {operation});

    Feed savedFeed = result.getValue()[0];
    siteLinksData.siteLinksFeedId = savedFeed.getId();
    FeedAttribute[] savedAttributes = savedFeed.getAttributes();
    siteLinksData.linkTextFeedAttributeId = savedAttributes[0].getId();
    siteLinksData.linkUrlFeedAttributeId = savedAttributes[1].getId();
    System.out.printf("Campaign with name %s and id %d with linkTextAttributeId %d"
        + " and linkUrlAttributeId %s was created.\n", savedFeed.getName(), savedFeed.getId(),
        savedAttributes[0].getId(), savedAttributes[1].getId());
  }
View Full Code Here

TOP

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

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.