Search in sources :

Example 1 with FeedItemTargetServiceInterface

use of com.google.api.ads.adwords.axis.v201809.cm.FeedItemTargetServiceInterface in project googleads-java-lib by googleads.

the class AddSiteLinksUsingFeeds method restrictFeedItemToAdGroup.

/**
 * Restricts the first feed item in {@code siteLinksData} to only serve with ads for the specified
 * ad group ID.
 */
private static void restrictFeedItemToAdGroup(AdWordsServicesInterface adWordsServices, AdWordsSession session, SiteLinksDataHolder siteLinksData, Long adGroupId) throws RemoteException {
    FeedItemTargetServiceInterface feedItemTargetService = adWordsServices.get(session, FeedItemTargetServiceInterface.class);
    FeedItemAdGroupTarget feedItemAdGroupTarget = new FeedItemAdGroupTarget();
    feedItemAdGroupTarget.setAdGroupId(adGroupId);
    feedItemAdGroupTarget.setFeedId(siteLinksData.siteLinksFeedId);
    feedItemAdGroupTarget.setFeedItemId(siteLinksData.siteLinkFeedItemIds.get(0));
    FeedItemTargetOperation operation = new FeedItemTargetOperation();
    operation.setOperand(feedItemAdGroupTarget);
    operation.setOperator(Operator.ADD);
    feedItemAdGroupTarget = (FeedItemAdGroupTarget) feedItemTargetService.mutate(new FeedItemTargetOperation[] { operation }).getValue(0);
    System.out.printf("Feed item target for feed ID %d and feed item ID %d was created to restrict serving to " + "ad group ID %d'.%n", feedItemAdGroupTarget.getFeedId(), feedItemAdGroupTarget.getFeedItemId(), feedItemAdGroupTarget.getAdGroupId());
}
Also used : FeedItemTargetServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.FeedItemTargetServiceInterface) FeedItemAdGroupTarget(com.google.api.ads.adwords.axis.v201809.cm.FeedItemAdGroupTarget) FeedItemTargetOperation(com.google.api.ads.adwords.axis.v201809.cm.FeedItemTargetOperation)

Example 2 with FeedItemTargetServiceInterface

use of com.google.api.ads.adwords.axis.v201809.cm.FeedItemTargetServiceInterface in project googleads-java-lib by googleads.

the class AddAdCustomizer method restrictFeedItemToAdGroup.

/**
 * Restricts the feed item to an ad group.
 */
private static void restrictFeedItemToAdGroup(AdWordsServicesInterface adWordsServices, AdWordsSession session, FeedItem feedItem, long adGroupId) throws RemoteException {
    // Get the FeedItemTargetingService.
    FeedItemTargetServiceInterface feedItemTargetService = adWordsServices.get(session, FeedItemTargetServiceInterface.class);
    FeedItemAdGroupTarget adGroupTarget = new FeedItemAdGroupTarget();
    adGroupTarget.setFeedId(feedItem.getFeedId());
    adGroupTarget.setFeedItemId(feedItem.getFeedItemId());
    adGroupTarget.setAdGroupId(adGroupId);
    FeedItemTargetOperation operation = new FeedItemTargetOperation();
    operation.setOperator(Operator.ADD);
    operation.setOperand(adGroupTarget);
    FeedItemTargetReturnValue returnValue = feedItemTargetService.mutate(new FeedItemTargetOperation[] { operation });
    FeedItemAdGroupTarget addedAdGroupTarget = (FeedItemAdGroupTarget) returnValue.getValue(0);
    System.out.printf("Feed item target for feed ID %d and feed item ID %d " + "was created to restrict serving to ad group ID %d.%n", addedAdGroupTarget.getFeedId(), addedAdGroupTarget.getFeedItemId(), addedAdGroupTarget.getAdGroupId());
}
Also used : FeedItemTargetServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.FeedItemTargetServiceInterface) FeedItemAdGroupTarget(com.google.api.ads.adwords.axis.v201809.cm.FeedItemAdGroupTarget) FeedItemTargetReturnValue(com.google.api.ads.adwords.axis.v201809.cm.FeedItemTargetReturnValue) FeedItemTargetOperation(com.google.api.ads.adwords.axis.v201809.cm.FeedItemTargetOperation)

Example 3 with FeedItemTargetServiceInterface

use of com.google.api.ads.adwords.axis.v201809.cm.FeedItemTargetServiceInterface in project googleads-java-lib by googleads.

the class AddSiteLinksUsingFeeds method restrictFeedItemToGeoTarget.

/**
 * Restricts the first feed item in {@code siteLinksData} to only serve with ads for the specified
 * location ID.
 */
private static void restrictFeedItemToGeoTarget(AdWordsServicesInterface adWordsServices, AdWordsSession session, FeedItem feedItem, Long locationId) throws RemoteException {
    FeedItemTargetServiceInterface feedItemTargetService = adWordsServices.get(session, FeedItemTargetServiceInterface.class);
    // Optional: Restrict the feed item to only serve with ads for the specified geo target.
    FeedItemCriterionTarget feedItemCriterionTarget = new FeedItemCriterionTarget();
    feedItemCriterionTarget.setFeedId(feedItem.getFeedId());
    feedItemCriterionTarget.setFeedItemId(feedItem.getFeedItemId());
    Location location = new Location();
    // The IDs can be found in the documentation or retrieved with the LocationCriterionService.
    location.setId(locationId);
    feedItemCriterionTarget.setCriterion(location);
    FeedItemTargetOperation operation = new FeedItemTargetOperation();
    operation.setOperand(feedItemCriterionTarget);
    operation.setOperator(Operator.ADD);
    feedItemCriterionTarget = (FeedItemCriterionTarget) feedItemTargetService.mutate(new FeedItemTargetOperation[] { operation }).getValue(0);
    System.out.printf("Feed item target for feed ID %d and feed item ID %d was created to restrict serving to " + "location ID %d'.%n", feedItemCriterionTarget.getFeedId(), feedItemCriterionTarget.getFeedItemId(), feedItemCriterionTarget.getCriterion().getId());
}
Also used : FeedItemTargetServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.FeedItemTargetServiceInterface) FeedItemCriterionTarget(com.google.api.ads.adwords.axis.v201809.cm.FeedItemCriterionTarget) FeedItemTargetOperation(com.google.api.ads.adwords.axis.v201809.cm.FeedItemTargetOperation) Location(com.google.api.ads.adwords.axis.v201809.cm.Location)

Aggregations

FeedItemTargetOperation (com.google.api.ads.adwords.axis.v201809.cm.FeedItemTargetOperation)3 FeedItemTargetServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.FeedItemTargetServiceInterface)3 FeedItemAdGroupTarget (com.google.api.ads.adwords.axis.v201809.cm.FeedItemAdGroupTarget)2 FeedItemCriterionTarget (com.google.api.ads.adwords.axis.v201809.cm.FeedItemCriterionTarget)1 FeedItemTargetReturnValue (com.google.api.ads.adwords.axis.v201809.cm.FeedItemTargetReturnValue)1 Location (com.google.api.ads.adwords.axis.v201809.cm.Location)1