Search in sources :

Example 11 with Location

use of com.google.api.ads.adwords.axis.v201809.cm.Location 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

Location (com.google.api.ads.adwords.axis.v201809.cm.Location)5 CampaignCriterion (com.google.api.ads.adwords.axis.v201809.cm.CampaignCriterion)3 CampaignCriterionServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.CampaignCriterionServiceInterface)3 Criterion (com.google.api.ads.adwords.axis.v201809.cm.Criterion)3 Keyword (com.google.api.ads.adwords.axis.v201809.cm.Keyword)3 Language (com.google.api.ads.adwords.axis.v201809.cm.Language)3 ArrayList (java.util.ArrayList)3 SelectorBuilder (com.google.api.ads.adwords.axis.utils.v201809.SelectorBuilder)2 ApiException (com.google.api.ads.adwords.axis.v201809.cm.ApiException)2 CampaignCriterionOperation (com.google.api.ads.adwords.axis.v201809.cm.CampaignCriterionOperation)2 CampaignCriterionReturnValue (com.google.api.ads.adwords.axis.v201809.cm.CampaignCriterionReturnValue)2 ConstantOperand (com.google.api.ads.adwords.axis.v201809.cm.ConstantOperand)2 FeedItem (com.google.api.ads.adwords.axis.v201809.cm.FeedItem)2 FeedItemGeoRestriction (com.google.api.ads.adwords.axis.v201809.cm.FeedItemGeoRestriction)2 FeedItemOperation (com.google.api.ads.adwords.axis.v201809.cm.FeedItemOperation)2 Function (com.google.api.ads.adwords.axis.v201809.cm.Function)2 Money (com.google.api.ads.adwords.axis.v201809.cm.Money)2 AdWordsServices (com.google.api.ads.adwords.axis.factory.AdWordsServices)1 ApiError (com.google.api.ads.adwords.axis.v201809.cm.ApiError)1 BiddingStrategyConfiguration (com.google.api.ads.adwords.axis.v201809.cm.BiddingStrategyConfiguration)1