public static void main(String[] args) { try { // Log SOAP XML request and response. AdWordsServiceLogger.log(); // Get AdWordsUser from "~/adwords.properties". AdWordsUser user = new AdWordsUser(); // Get the ExperimentService. ExperimentServiceInterface experimentService = user.getService(AdWordsService.V201109_1.EXPERIMENT_SERVICE); Long campaignId = Long.parseLong("INSET_CAMPAIGN_ID_HERE"); // Create selector. Selector selector = new Selector(); selector.setFields( new String[] { "Name", "Id", "ControlId", "AdGroupsCount", "AdGroupCriteriaCount", "AdGroupAdsCount" }); selector.setOrdering(new OrderBy[] {new OrderBy("Name", SortOrder.ASCENDING)}); // Create predicates. Predicate campaignIdPredicate = new Predicate("CampaignId", PredicateOperator.IN, new String[] {campaignId.toString()}); selector.setPredicates(new Predicate[] {campaignIdPredicate}); // Get all experiments. ExperimentPage page = experimentService.get(selector); if (page.getEntries() != null) { for (Experiment experiment : page.getEntries()) { System.out.println( "Experiment with name \"" + experiment.getName() + "\", id \"" + experiment.getId() + "\", and control id \"" + experiment.getControlId() + "\" was found.\nIt includes " + experiment.getExperimentSummaryStats().getAdGroupsCount() + " ad groups, " + experiment.getExperimentSummaryStats().getAdGroupCriteriaCount() + " criteria, and " + experiment.getExperimentSummaryStats().getAdGroupAdsCount() + " ads."); } } else { System.out.println("No experiments were found."); } } catch (Exception e) { e.printStackTrace(); } }
public static void main(String[] args) { try { // Log SOAP XML request and response. AdWordsServiceLogger.log(); // Get AdWordsUser from "~/adwords.properties". AdWordsUser user = new AdWordsUser(); // Get the ConversionTrackerService. ConversionTrackerServiceInterface service = user.getService(AdWordsService.V201109_1.CONVERSION_TRACKER_SERVICE); // Create selector. Selector selector = new Selector(); selector.setFields(new String[] {"Name", "Status", "Category"}); selector.setOrdering(new OrderBy[] {new OrderBy("Name", SortOrder.ASCENDING)}); // Get all conversions. ConversionTrackerPage page = service.get(selector); // Display conversions. if (page != null && page.getEntries() != null) { for (ConversionTracker conversionTracker : page.getEntries()) { if (conversionTracker instanceof AdWordsConversionTracker) { AdWordsConversionTracker newAdWordsConversionTracker = (AdWordsConversionTracker) conversionTracker; System.out.printf( "Conversion with id \"%d\", name \"%s\", status \"%s\", " + "category \"%s\" and snippet \"%s\" was found.\n", newAdWordsConversionTracker.getId(), newAdWordsConversionTracker.getName(), newAdWordsConversionTracker.getStatus(), newAdWordsConversionTracker.getCategory(), newAdWordsConversionTracker.getSnippet()); } else { System.out.printf( "Conversion with id \"%d\", name \"%s\", status \"%s\", " + "category \"%s\" was found.\n", conversionTracker.getId(), conversionTracker.getName(), conversionTracker.getStatus(), conversionTracker.getCategory()); } } } else { System.out.println("No conversions were found."); } } catch (Exception e) { e.printStackTrace(); } }