/// <summary>Snippet for GetFeedMapping</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GetFeedMapping() { // Create client FeedMappingServiceClient feedMappingServiceClient = FeedMappingServiceClient.Create(); // Initialize request argument(s) string resourceName = "customers/[CUSTOMER]/feedMappings/[FEED_MAPPING]"; // Make the request FeedMapping response = feedMappingServiceClient.GetFeedMapping(resourceName); }
/// <summary>Snippet for GetFeedMapping</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GetFeedMappingResourceNames() { // Create client FeedMappingServiceClient feedMappingServiceClient = FeedMappingServiceClient.Create(); // Initialize request argument(s) FeedMappingName resourceName = FeedMappingName.FromCustomerFeedMapping("[CUSTOMER]", "[FEED_MAPPING]"); // Make the request FeedMapping response = feedMappingServiceClient.GetFeedMapping(resourceName); }
/// <summary>Snippet for GetFeedMappingAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task GetFeedMappingAsync() { // Create client FeedMappingServiceClient feedMappingServiceClient = await FeedMappingServiceClient.CreateAsync(); // Initialize request argument(s) string resourceName = "customers/[CUSTOMER]/feedMappings/[FEED_MAPPING]"; // Make the request FeedMapping response = await feedMappingServiceClient.GetFeedMappingAsync(resourceName); }
/// <summary>Snippet for GetFeedMappingAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task GetFeedMappingResourceNamesAsync() { // Create client FeedMappingServiceClient feedMappingServiceClient = await FeedMappingServiceClient.CreateAsync(); // Initialize request argument(s) FeedMappingName resourceName = FeedMappingName.FromCustomerFeedFeedMapping("[CUSTOMER_ID]", "[FEED_ID]", "[FEED_MAPPING_ID]"); // Make the request FeedMapping response = await feedMappingServiceClient.GetFeedMappingAsync(resourceName); }
/// <summary>Snippet for GetFeedMapping</summary> public void GetFeedMappingResourceNames() { // Snippet: GetFeedMapping(FeedMappingName, CallSettings) // Create client FeedMappingServiceClient feedMappingServiceClient = FeedMappingServiceClient.Create(); // Initialize request argument(s) FeedMappingName resourceName = FeedMappingName.FromCustomerFeedFeedMapping("[CUSTOMER_ID]", "[FEED_ID]", "[FEED_MAPPING_ID]"); // Make the request FeedMapping response = feedMappingServiceClient.GetFeedMapping(resourceName); // End snippet }
/// <summary>Snippet for GetFeedMapping</summary> public void GetFeedMapping() { // Snippet: GetFeedMapping(string, CallSettings) // Create client FeedMappingServiceClient feedMappingServiceClient = FeedMappingServiceClient.Create(); // Initialize request argument(s) string resourceName = "customers/[CUSTOMER_ID]/feedMappings/[FEED_ID]~[FEED_MAPPING_ID]"; // Make the request FeedMapping response = feedMappingServiceClient.GetFeedMapping(resourceName); // End snippet }
/// <summary>Snippet for GetFeedMapping</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GetFeedMappingRequestObject() { // Create client FeedMappingServiceClient feedMappingServiceClient = FeedMappingServiceClient.Create(); // Initialize request argument(s) GetFeedMappingRequest request = new GetFeedMappingRequest { ResourceNameAsFeedMappingName = FeedMappingName.FromCustomerFeedFeedMapping("[CUSTOMER_ID]", "[FEED_ID]", "[FEED_MAPPING_ID]"), }; // Make the request FeedMapping response = feedMappingServiceClient.GetFeedMapping(request); }
/// <summary>Snippet for MutateFeedMappings</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateFeedMappings() { // Create client FeedMappingServiceClient feedMappingServiceClient = FeedMappingServiceClient.Create(); // Initialize request argument(s) string customerId = ""; IEnumerable <FeedMappingOperation> operations = new FeedMappingOperation[] { new FeedMappingOperation(), }; // Make the request MutateFeedMappingsResponse response = feedMappingServiceClient.MutateFeedMappings(customerId, operations); }
/// <summary>Snippet for GetFeedMappingAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task GetFeedMappingRequestObjectAsync() { // Create client FeedMappingServiceClient feedMappingServiceClient = await FeedMappingServiceClient.CreateAsync(); // Initialize request argument(s) GetFeedMappingRequest request = new GetFeedMappingRequest { ResourceNameAsFeedMappingName = FeedMappingName.FromCustomerFeedMapping("[CUSTOMER]", "[FEED_MAPPING]"), }; // Make the request FeedMapping response = await feedMappingServiceClient.GetFeedMappingAsync(request); }
/// <summary>Snippet for GetFeedMappingAsync</summary> public async Task GetFeedMappingAsync() { // Snippet: GetFeedMappingAsync(string, CallSettings) // Additional: GetFeedMappingAsync(string, CancellationToken) // Create client FeedMappingServiceClient feedMappingServiceClient = await FeedMappingServiceClient.CreateAsync(); // Initialize request argument(s) string resourceName = "customers/[CUSTOMER_ID]/feedMappings/[FEED_ID]~[FEED_MAPPING_ID]"; // Make the request FeedMapping response = await feedMappingServiceClient.GetFeedMappingAsync(resourceName); // End snippet }
/// <summary>Snippet for GetFeedMappingAsync</summary> public async Task GetFeedMappingResourceNamesAsync() { // Snippet: GetFeedMappingAsync(FeedMappingName, CallSettings) // Additional: GetFeedMappingAsync(FeedMappingName, CancellationToken) // Create client FeedMappingServiceClient feedMappingServiceClient = await FeedMappingServiceClient.CreateAsync(); // Initialize request argument(s) FeedMappingName resourceName = FeedMappingName.FromCustomerFeedFeedMapping("[CUSTOMER_ID]", "[FEED_ID]", "[FEED_MAPPING_ID]"); // Make the request FeedMapping response = await feedMappingServiceClient.GetFeedMappingAsync(resourceName); // End snippet }
/// <summary> /// Creates a feed mapping, which tells Google Ads how to interpret this data to display /// additional sitelink information on ads. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The customer ID for which the call is made.</param> /// <param name="feed">The feed for which the operation will be created.</param> private void CreateFeedMapping(GoogleAdsClient client, long customerId, Feed feed) { FeedMappingServiceClient feedMappingServiceClient = client.GetService(Services.V4.FeedMappingService); FeedMapping feedMapping = new FeedMapping { PlaceholderType = PlaceholderTypeEnum.Types.PlaceholderType.Sitelink, Feed = feed.ResourceName, }; foreach (FeedAttribute feedAttribute in feed.Attributes) { AttributeFieldMapping attributeFieldMapping = new AttributeFieldMapping() { FeedAttributeId = feedAttribute.Id }; switch (feedAttribute.Name) { case "Link Text": attributeFieldMapping.SitelinkField = SitelinkPlaceholderField.Text; break; case "Link Final URL": attributeFieldMapping.SitelinkField = SitelinkPlaceholderField.FinalUrls; break; case "Line 1": attributeFieldMapping.SitelinkField = SitelinkPlaceholderField.Line1; break; case "Line 2": attributeFieldMapping.SitelinkField = SitelinkPlaceholderField.Line2; break; } feedMapping.AttributeFieldMappings.Add(attributeFieldMapping); } FeedMappingOperation operation = new FeedMappingOperation() { Create = feedMapping }; MutateFeedMappingsResponse response = feedMappingServiceClient.MutateFeedMappings (customerId.ToString(), new[] { operation }); Console.WriteLine($"Created feed mapping '{response.Results.First().ResourceName}'"); }
/// <summary> /// Creates a feed mapping for a given feed. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The Google Ads customer ID for which the call is made.</param> /// <param name="feedResourceName">The feed resource for which feed mapping is created. /// </param> /// <param name="feedAttributes">The feed attributes.</param> private void CreateFeedMapping(GoogleAdsClient client, long customerId, string feedResourceName, Dictionary <DsaPageFeedCriterionField, FeedAttribute> feedAttributes ) { // Get the FeedMappingService. FeedMappingServiceClient feedMappingService = client.GetService( Services.V3.FeedMappingService); FeedMapping feedMapping = new FeedMapping() { CriterionType = FeedMappingCriterionType.DsaPageFeed, Feed = feedResourceName, // Map the FeedAttributeId to the fieldId constants. AttributeFieldMappings = { new AttributeFieldMapping() { FeedAttributeId = feedAttributes[DsaPageFeedCriterionField.PageUrl].Id, DsaPageFeedField = DsaPageFeedCriterionField.PageUrl }, new AttributeFieldMapping() { FeedAttributeId = feedAttributes[DsaPageFeedCriterionField.Label].Id, DsaPageFeedField = DsaPageFeedCriterionField.Label } } }; // Create the operation. FeedMappingOperation operation = new FeedMappingOperation() { Create = feedMapping }; // Add the FeedMapping. MutateFeedMappingsResponse response = feedMappingService.MutateFeedMappings(customerId.ToString(), new[] { operation }); // Display the results. foreach (MutateFeedMappingResult result in response.Results) { Console.WriteLine($"Created feed mapping with resource name" + $" '{result.ResourceName}'"); } }
/// <summary> /// Creates a feed mapping and sets the feed as an ad customizer feed. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The Google Ads customer ID for which the call is made.</param> /// <param name="feedResourceName">The resource name of the feed.</param> /// <param name="feedAttributes">The attributes of the feed.</param> private void CreateAdCustomizerMapping(GoogleAdsClient client, long customerId, string feedResourceName, Dictionary <string, FeedAttribute> feedAttributes) { // Get the FeedMappingService. FeedMappingServiceClient feedMappingService = client.GetService(Services.V4.FeedMappingService); // Map the feed attributes to ad customizer placeholder fields. // For a full list of ad customizer placeholder fields, see // https://developers.google.com/google-ads/api/reference/rpc/latest/AdCustomizerPlaceholderFieldEnum.AdCustomizerPlaceholderField AttributeFieldMapping nameFieldMapping = new AttributeFieldMapping() { FeedAttributeId = feedAttributes["Name"].Id, AdCustomizerField = AdCustomizerPlaceholderField.String }; AttributeFieldMapping priceFieldMapping = new AttributeFieldMapping() { FeedAttributeId = feedAttributes["Price"].Id, AdCustomizerField = AdCustomizerPlaceholderField.Price }; AttributeFieldMapping dateFieldMapping = new AttributeFieldMapping() { FeedAttributeId = feedAttributes["Date"].Id, AdCustomizerField = AdCustomizerPlaceholderField.Date }; FeedMapping feedMapping = new FeedMapping() { Feed = feedResourceName, PlaceholderType = PlaceholderType.AdCustomizer, AttributeFieldMappings = { nameFieldMapping, priceFieldMapping, dateFieldMapping } }; FeedMappingOperation operation = new FeedMappingOperation() { Create = feedMapping }; MutateFeedMappingsResponse response = feedMappingService.MutateFeedMappings(customerId.ToString(), new[] { operation }); Console.WriteLine($"Added feed mapping with resource name" + $" '{response.Results[0].ResourceName}'."); }
/// <summary>Snippet for GetFeedMappingAsync</summary> public async Task GetFeedMappingRequestObjectAsync() { // Snippet: GetFeedMappingAsync(GetFeedMappingRequest, CallSettings) // Additional: GetFeedMappingAsync(GetFeedMappingRequest, CancellationToken) // Create client FeedMappingServiceClient feedMappingServiceClient = await FeedMappingServiceClient.CreateAsync(); // Initialize request argument(s) GetFeedMappingRequest request = new GetFeedMappingRequest { ResourceNameAsFeedMappingName = FeedMappingName.FromCustomerFeedMapping("[CUSTOMER]", "[FEED_MAPPING]"), }; // Make the request FeedMapping response = await feedMappingServiceClient.GetFeedMappingAsync(request); // End snippet }
/// <summary>Snippet for MutateFeedMappings</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateFeedMappingsRequestObject() { // Create client FeedMappingServiceClient feedMappingServiceClient = FeedMappingServiceClient.Create(); // Initialize request argument(s) MutateFeedMappingsRequest request = new MutateFeedMappingsRequest { CustomerId = "", Operations = { new FeedMappingOperation(), }, PartialFailure = false, ValidateOnly = false, }; // Make the request MutateFeedMappingsResponse response = feedMappingServiceClient.MutateFeedMappings(request); }
/// <summary>Snippet for MutateFeedMappingsAsync</summary> public async Task MutateFeedMappingsAsync() { // Snippet: MutateFeedMappingsAsync(string, IEnumerable<FeedMappingOperation>, CallSettings) // Additional: MutateFeedMappingsAsync(string, IEnumerable<FeedMappingOperation>, CancellationToken) // Create client FeedMappingServiceClient feedMappingServiceClient = await FeedMappingServiceClient.CreateAsync(); // Initialize request argument(s) string customerId = ""; IEnumerable <FeedMappingOperation> operations = new FeedMappingOperation[] { new FeedMappingOperation(), }; // Make the request MutateFeedMappingsResponse response = await feedMappingServiceClient.MutateFeedMappingsAsync(customerId, operations); // End snippet }
/// <summary>Snippet for MutateFeedMappingsAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task MutateFeedMappingsRequestObjectAsync() { // Create client FeedMappingServiceClient feedMappingServiceClient = await FeedMappingServiceClient.CreateAsync(); // Initialize request argument(s) MutateFeedMappingsRequest request = new MutateFeedMappingsRequest { CustomerId = "", Operations = { new FeedMappingOperation(), }, PartialFailure = false, ValidateOnly = false, ResponseContentType = ResponseContentTypeEnum.Types.ResponseContentType.Unspecified, }; // Make the request MutateFeedMappingsResponse response = await feedMappingServiceClient.MutateFeedMappingsAsync(request); }
/// <summary>Snippet for MutateFeedMappings</summary> public void MutateFeedMappingsRequestObject() { // Snippet: MutateFeedMappings(MutateFeedMappingsRequest, CallSettings) // Create client FeedMappingServiceClient feedMappingServiceClient = FeedMappingServiceClient.Create(); // Initialize request argument(s) MutateFeedMappingsRequest request = new MutateFeedMappingsRequest { CustomerId = "", Operations = { new FeedMappingOperation(), }, PartialFailure = false, ValidateOnly = false, ResponseContentType = ResponseContentTypeEnum.Types.ResponseContentType.Unspecified, }; // Make the request MutateFeedMappingsResponse response = feedMappingServiceClient.MutateFeedMappings(request); // End snippet }
/// <summary>Snippet for MutateFeedMappingsAsync</summary> public async Task MutateFeedMappingsRequestObjectAsync() { // Snippet: MutateFeedMappingsAsync(MutateFeedMappingsRequest, CallSettings) // Additional: MutateFeedMappingsAsync(MutateFeedMappingsRequest, CancellationToken) // Create client FeedMappingServiceClient feedMappingServiceClient = await FeedMappingServiceClient.CreateAsync(); // Initialize request argument(s) MutateFeedMappingsRequest request = new MutateFeedMappingsRequest { CustomerId = "", Operations = { new FeedMappingOperation(), }, PartialFailure = false, ValidateOnly = false, }; // Make the request MutateFeedMappingsResponse response = await feedMappingServiceClient.MutateFeedMappingsAsync(request); // End snippet }
/// <summary> /// Creates a feed mapping for a given feed. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The Google Ads customer ID for which the real estate feed is /// added.</param> /// <param name="feedAttributes">The feed attributes.</param> /// <param name="feedResourceName">The resource name of the feed.</param> private void CreateFeedMapping(GoogleAdsClient client, long customerId, Dictionary <RealEstatePlaceholderField, FeedAttribute> feedAttributes, string feedResourceName) { // Get the FeedMappingServiceClient. FeedMappingServiceClient feedMappingService = client.GetService( Services.V3.FeedMappingService); // Maps the FeedAttributeIds to the placeholder values. The FeedAttributeId is the // ID of the FeedAttribute created in the CreatedFeed method. This can be thought of // as the generic ID of the column of the new feed. The placeholder value specifies // the type of column this is in the context of a real estate feed (e.g. // a LISTING_ID or LISTING_NAME). The FeedMapping associates the feed column by ID to // this type and controls how the feed attributes are presented in dynamic content. // See https://developers.google.com/google-ads/api/reference/rpc/Google.Ads.GoogleAds.V3.enums#Google.Ads.GoogleAds.V3.enums.RealEstatePlaceholderFieldEnum.RealEstatePlaceholderField // for the full list of placeholder values. AttributeFieldMapping listingIdMapping = new AttributeFieldMapping() { FeedAttributeId = feedAttributes[RealEstatePlaceholderField.ListingId].Id, RealEstateField = RealEstatePlaceholderField.ListingId }; AttributeFieldMapping listingNameMapping = new AttributeFieldMapping() { FeedAttributeId = feedAttributes[RealEstatePlaceholderField.ListingName].Id, RealEstateField = RealEstatePlaceholderField.ListingName }; AttributeFieldMapping finalUrlsMapping = new AttributeFieldMapping() { FeedAttributeId = feedAttributes[RealEstatePlaceholderField.FinalUrls].Id, RealEstateField = RealEstatePlaceholderField.FinalUrls }; AttributeFieldMapping imageUrlMapping = new AttributeFieldMapping() { FeedAttributeId = feedAttributes[RealEstatePlaceholderField.ImageUrl].Id, RealEstateField = RealEstatePlaceholderField.ImageUrl }; AttributeFieldMapping contextualKeywordsMapping = new AttributeFieldMapping() { FeedAttributeId = feedAttributes[RealEstatePlaceholderField.ContextualKeywords].Id, RealEstateField = RealEstatePlaceholderField.ContextualKeywords }; // Creates the feed mapping. FeedMapping feedMapping = new FeedMapping() { PlaceholderType = PlaceholderType.DynamicRealEstate, Feed = feedResourceName, AttributeFieldMappings = { listingIdMapping, listingNameMapping, finalUrlsMapping, imageUrlMapping, contextualKeywordsMapping } }; // Creates the operation. FeedMappingOperation operation = new FeedMappingOperation() { Create = feedMapping }; // Adds the FeedMapping. MutateFeedMappingsResponse response = feedMappingService.MutateFeedMappings( customerId.ToString(), new[] { operation }); // Displays the results. foreach (MutateFeedMappingResult result in response.Results) { Console.WriteLine($"Created feed mapping with resource name" + $" '{result.ResourceName}'."); } }
/// <summary> /// Creates a feed mapping for a given feed. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The Google Ads customer ID for which the flights feed is /// added.</param> /// <param name="feedAttributes">The feed attributes.</param> /// <param name="feedResourceName">The resource name of the feed.</param> private void CreateFeedMapping(GoogleAdsClient client, long customerId, Dictionary <FlightPlaceholderField, FeedAttribute> feedAttributes, string feedResourceName) { // Get the FeedMappingServiceClient. FeedMappingServiceClient feedMappingService = client.GetService( Services.V5.FeedMappingService); // Maps the FeedAttributeIds to the fieldId constants. AttributeFieldMapping flightDescriptionMapping = new AttributeFieldMapping() { FeedAttributeId = feedAttributes[FlightPlaceholderField.FlightDescription].Id, FlightField = FlightPlaceholderField.FlightDescription }; AttributeFieldMapping destinationIdMapping = new AttributeFieldMapping() { FeedAttributeId = feedAttributes[FlightPlaceholderField.DestinationId].Id, FlightField = FlightPlaceholderField.DestinationId }; AttributeFieldMapping flightPriceMapping = new AttributeFieldMapping() { FeedAttributeId = feedAttributes[FlightPlaceholderField.FlightPrice].Id, FlightField = FlightPlaceholderField.FlightPrice }; AttributeFieldMapping flightSalePriceMapping = new AttributeFieldMapping() { FeedAttributeId = feedAttributes[FlightPlaceholderField.FlightSalePrice].Id, FlightField = FlightPlaceholderField.FlightSalePrice }; AttributeFieldMapping finalUrlsMapping = new AttributeFieldMapping() { FeedAttributeId = feedAttributes[FlightPlaceholderField.FinalUrls].Id, FlightField = FlightPlaceholderField.FinalUrls }; // Creates the feed mapping. FeedMapping feedMapping = new FeedMapping() { PlaceholderType = PlaceholderType.DynamicFlight, Feed = feedResourceName, AttributeFieldMappings = { flightDescriptionMapping, destinationIdMapping, flightPriceMapping, flightSalePriceMapping, finalUrlsMapping } }; // Creates the operation. FeedMappingOperation operation = new FeedMappingOperation() { Create = feedMapping }; // Adds the FeedMapping. MutateFeedMappingsResponse response = feedMappingService.MutateFeedMappings( customerId.ToString(), new[] { operation }); // Displays the results. foreach (MutateFeedMappingResult result in response.Results) { Console.WriteLine($"Created feed mapping with resource name" + $" '{result.ResourceName}'."); } }