/// <summary> /// Creates a campaign feed, which tells Google Ads which campaigns to use the provided /// data with. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The customer ID for which the call is made.</param> /// <param name="campaignId">The campaign to receive the feed.</param> /// <param name="feed">The feed to connect to the campaign.</param> private void CreateCampaignFeed(GoogleAdsClient client, long customerId, long campaignId, Feed feed) { CampaignFeedServiceClient campaignFeedServiceClient = client.GetService(Services.V4.CampaignFeedService); // Fetch the Feed Item IDs and collapse them into a single comma-separated string. List <long> feedItemIds = feed.Attributes.Select(attr => attr.Id.Value).ToList(); string aggregatedFeedItemIds = string.Join(",", feedItemIds); CampaignFeed campaignFeed = new CampaignFeed() { Feed = feed.ResourceName, Campaign = ResourceNames.Campaign(customerId, campaignId), MatchingFunction = new MatchingFunction() { FunctionString = $"AND(IN(FEED_ITEM_ID,{{ {aggregatedFeedItemIds} }})," + "EQUALS(CONTEXT.DEVICE,'Mobile'))" } }; campaignFeed.PlaceholderTypes.Add(PlaceholderTypeEnum.Types.PlaceholderType.Sitelink); CampaignFeedOperation operation = new CampaignFeedOperation() { Create = campaignFeed }; MutateCampaignFeedsResponse response = campaignFeedServiceClient.MutateCampaignFeeds( customerId.ToString(), new[] { operation }); Console.WriteLine($"Created campaign feed '{response.Results.First().ResourceName}'"); }
/// <summary>Snippet for GetCampaignFeed</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GetCampaignFeed() { // Create client CampaignFeedServiceClient campaignFeedServiceClient = CampaignFeedServiceClient.Create(); // Initialize request argument(s) string resourceName = "customers/[CUSTOMER_ID]/campaignFeeds/[CAMPAIGN_ID]~[FEED_ID]"; // Make the request CampaignFeed response = campaignFeedServiceClient.GetCampaignFeed(resourceName); }
/// <summary>Snippet for GetCampaignFeed</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GetCampaignFeedResourceNames() { // Create client CampaignFeedServiceClient campaignFeedServiceClient = CampaignFeedServiceClient.Create(); // Initialize request argument(s) CampaignFeedName resourceName = CampaignFeedName.FromCustomerCampaignFeed("[CUSTOMER_ID]", "[CAMPAIGN_ID]", "[FEED_ID]"); // Make the request CampaignFeed response = campaignFeedServiceClient.GetCampaignFeed(resourceName); }
/// <summary>Snippet for GetCampaignFeedAsync</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 GetCampaignFeedAsync() { // Create client CampaignFeedServiceClient campaignFeedServiceClient = await CampaignFeedServiceClient.CreateAsync(); // Initialize request argument(s) string resourceName = "customers/[CUSTOMER]/campaignFeeds/[CAMPAIGN_FEED]"; // Make the request CampaignFeed response = await campaignFeedServiceClient.GetCampaignFeedAsync(resourceName); }
/// <summary>Snippet for GetCampaignFeedAsync</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 GetCampaignFeedResourceNamesAsync() { // Create client CampaignFeedServiceClient campaignFeedServiceClient = await CampaignFeedServiceClient.CreateAsync(); // Initialize request argument(s) CampaignFeedName resourceName = CampaignFeedName.FromCustomerCampaignFeed("[CUSTOMER]", "[CAMPAIGN_FEED]"); // Make the request CampaignFeed response = await campaignFeedServiceClient.GetCampaignFeedAsync(resourceName); }
/// <summary>Snippet for GetCampaignFeed</summary> public void GetCampaignFeedResourceNames() { // Snippet: GetCampaignFeed(CampaignFeedName, CallSettings) // Create client CampaignFeedServiceClient campaignFeedServiceClient = CampaignFeedServiceClient.Create(); // Initialize request argument(s) CampaignFeedName resourceName = CampaignFeedName.FromCustomerCampaignFeed("[CUSTOMER]", "[CAMPAIGN_FEED]"); // Make the request CampaignFeed response = campaignFeedServiceClient.GetCampaignFeed(resourceName); // End snippet }
/// <summary>Snippet for GetCampaignFeed</summary> public void GetCampaignFeed() { // Snippet: GetCampaignFeed(string, CallSettings) // Create client CampaignFeedServiceClient campaignFeedServiceClient = CampaignFeedServiceClient.Create(); // Initialize request argument(s) string resourceName = "customers/[CUSTOMER]/campaignFeeds/[CAMPAIGN_FEED]"; // Make the request CampaignFeed response = campaignFeedServiceClient.GetCampaignFeed(resourceName); // End snippet }
/// <summary>Snippet for GetCampaignFeed</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GetCampaignFeedRequestObject() { // Create client CampaignFeedServiceClient campaignFeedServiceClient = CampaignFeedServiceClient.Create(); // Initialize request argument(s) GetCampaignFeedRequest request = new GetCampaignFeedRequest { ResourceNameAsCampaignFeedName = CampaignFeedName.FromCustomerCampaignFeed("[CUSTOMER]", "[CAMPAIGN_FEED]"), }; // Make the request CampaignFeed response = campaignFeedServiceClient.GetCampaignFeed(request); }
/// <summary>Snippet for GetCampaignFeedAsync</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 GetCampaignFeedRequestObjectAsync() { // Create client CampaignFeedServiceClient campaignFeedServiceClient = await CampaignFeedServiceClient.CreateAsync(); // Initialize request argument(s) GetCampaignFeedRequest request = new GetCampaignFeedRequest { ResourceNameAsCampaignFeedName = CampaignFeedName.FromCustomerCampaignFeed("[CUSTOMER_ID]", "[CAMPAIGN_ID]", "[FEED_ID]"), }; // Make the request CampaignFeed response = await campaignFeedServiceClient.GetCampaignFeedAsync(request); }
/// <summary>Snippet for MutateCampaignFeeds</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateCampaignFeeds() { // Create client CampaignFeedServiceClient campaignFeedServiceClient = CampaignFeedServiceClient.Create(); // Initialize request argument(s) string customerId = ""; IEnumerable <CampaignFeedOperation> operations = new CampaignFeedOperation[] { new CampaignFeedOperation(), }; // Make the request MutateCampaignFeedsResponse response = campaignFeedServiceClient.MutateCampaignFeeds(customerId, operations); }
/// <summary>Snippet for GetCampaignFeedAsync</summary> public async Task GetCampaignFeedResourceNamesAsync() { // Snippet: GetCampaignFeedAsync(CampaignFeedName, CallSettings) // Additional: GetCampaignFeedAsync(CampaignFeedName, CancellationToken) // Create client CampaignFeedServiceClient campaignFeedServiceClient = await CampaignFeedServiceClient.CreateAsync(); // Initialize request argument(s) CampaignFeedName resourceName = CampaignFeedName.FromCustomerCampaignFeed("[CUSTOMER_ID]", "[CAMPAIGN_ID]", "[FEED_ID]"); // Make the request CampaignFeed response = await campaignFeedServiceClient.GetCampaignFeedAsync(resourceName); // End snippet }
/// <summary>Snippet for GetCampaignFeedAsync</summary> public async Task GetCampaignFeedAsync() { // Snippet: GetCampaignFeedAsync(string, CallSettings) // Additional: GetCampaignFeedAsync(string, CancellationToken) // Create client CampaignFeedServiceClient campaignFeedServiceClient = await CampaignFeedServiceClient.CreateAsync(); // Initialize request argument(s) string resourceName = "customers/[CUSTOMER_ID]/campaignFeeds/[CAMPAIGN_ID]~[FEED_ID]"; // Make the request CampaignFeed response = await campaignFeedServiceClient.GetCampaignFeedAsync(resourceName); // End snippet }
/// <summary>Snippet for GetCampaignFeedAsync</summary> public async Task GetCampaignFeedRequestObjectAsync() { // Snippet: GetCampaignFeedAsync(GetCampaignFeedRequest, CallSettings) // Additional: GetCampaignFeedAsync(GetCampaignFeedRequest, CancellationToken) // Create client CampaignFeedServiceClient campaignFeedServiceClient = await CampaignFeedServiceClient.CreateAsync(); // Initialize request argument(s) GetCampaignFeedRequest request = new GetCampaignFeedRequest { ResourceNameAsCampaignFeedName = CampaignFeedName.FromCustomerCampaignFeed("[CUSTOMER]", "[CAMPAIGN_FEED]"), }; // Make the request CampaignFeed response = await campaignFeedServiceClient.GetCampaignFeedAsync(request); // End snippet }
/// <summary>Snippet for MutateCampaignFeedsAsync</summary> public async Task MutateCampaignFeedsAsync() { // Snippet: MutateCampaignFeedsAsync(string, IEnumerable<CampaignFeedOperation>, CallSettings) // Additional: MutateCampaignFeedsAsync(string, IEnumerable<CampaignFeedOperation>, CancellationToken) // Create client CampaignFeedServiceClient campaignFeedServiceClient = await CampaignFeedServiceClient.CreateAsync(); // Initialize request argument(s) string customerId = ""; IEnumerable <CampaignFeedOperation> operations = new CampaignFeedOperation[] { new CampaignFeedOperation(), }; // Make the request MutateCampaignFeedsResponse response = await campaignFeedServiceClient.MutateCampaignFeedsAsync(customerId, operations); // End snippet }
/// <summary>Snippet for MutateCampaignFeeds</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateCampaignFeedsRequestObject() { // Create client CampaignFeedServiceClient campaignFeedServiceClient = CampaignFeedServiceClient.Create(); // Initialize request argument(s) MutateCampaignFeedsRequest request = new MutateCampaignFeedsRequest { CustomerId = "", Operations = { new CampaignFeedOperation(), }, PartialFailure = false, ValidateOnly = false, }; // Make the request MutateCampaignFeedsResponse response = campaignFeedServiceClient.MutateCampaignFeeds(request); }
/// <summary>Snippet for MutateCampaignFeedsAsync</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 MutateCampaignFeedsRequestObjectAsync() { // Create client CampaignFeedServiceClient campaignFeedServiceClient = await CampaignFeedServiceClient.CreateAsync(); // Initialize request argument(s) MutateCampaignFeedsRequest request = new MutateCampaignFeedsRequest { CustomerId = "", Operations = { new CampaignFeedOperation(), }, PartialFailure = false, ValidateOnly = false, ResponseContentType = ResponseContentTypeEnum.Types.ResponseContentType.Unspecified, }; // Make the request MutateCampaignFeedsResponse response = await campaignFeedServiceClient.MutateCampaignFeedsAsync(request); }
/// <summary>Snippet for MutateCampaignFeeds</summary> public void MutateCampaignFeedsRequestObject() { // Snippet: MutateCampaignFeeds(MutateCampaignFeedsRequest, CallSettings) // Create client CampaignFeedServiceClient campaignFeedServiceClient = CampaignFeedServiceClient.Create(); // Initialize request argument(s) MutateCampaignFeedsRequest request = new MutateCampaignFeedsRequest { CustomerId = "", Operations = { new CampaignFeedOperation(), }, PartialFailure = false, ValidateOnly = false, ResponseContentType = ResponseContentTypeEnum.Types.ResponseContentType.Unspecified, }; // Make the request MutateCampaignFeedsResponse response = campaignFeedServiceClient.MutateCampaignFeeds(request); // End snippet }
/// <summary> /// Creates the campaign feed. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The customer ID for which the call is made.</param> /// <param name="campaignId">The campaign ID for which the affiliate location extensions /// are added.</param> /// <param name="feedMapping">The affliate location extension feedmapping for /// <paramref name="feedResourceName"/></param> /// <param name="feedResourceName">The feed resource name.</param> /// <param name="chainId">The retail chain ID.</param> private static void CreateCampaignFeed(GoogleAdsClient client, long customerId, long campaignId, FeedMapping feedMapping, string feedResourceName, long chainId) { // Get the CampaignFeedService. CampaignFeedServiceClient campaignFeedService = client.GetService( Services.V5.CampaignFeedService); long attributeIdForChainId = GetAttributeIdForChainId(feedMapping); string feedId = FeedName.Parse(feedResourceName).FeedId; string matchingFunction = $"IN(FeedAttribute[{feedId}, {attributeIdForChainId}], {chainId})"; // Adds a CampaignFeed that associates the feed with this campaign for // the AFFILIATE_LOCATION placeholder type. CampaignFeed campaignFeed = new CampaignFeed() { Feed = feedResourceName, PlaceholderTypes = { PlaceholderType.AffiliateLocation }, MatchingFunction = new MatchingFunction() { FunctionString = matchingFunction }, Campaign = ResourceNames.Campaign(customerId, campaignId), }; CampaignFeedOperation operation = new CampaignFeedOperation() { Create = campaignFeed }; MutateCampaignFeedsResponse campaignFeedsResponse = campaignFeedService.MutateCampaignFeeds( customerId.ToString(), new[] { operation }); // Displays the result. string addedCampaignFeed = campaignFeedsResponse.Results[0].ResourceName; Console.WriteLine($"Campaign feed created with resource name: {addedCampaignFeed}."); return; }
/// <summary>Snippet for MutateCampaignFeedsAsync</summary> public async Task MutateCampaignFeedsRequestObjectAsync() { // Snippet: MutateCampaignFeedsAsync(MutateCampaignFeedsRequest, CallSettings) // Additional: MutateCampaignFeedsAsync(MutateCampaignFeedsRequest, CancellationToken) // Create client CampaignFeedServiceClient campaignFeedServiceClient = await CampaignFeedServiceClient.CreateAsync(); // Initialize request argument(s) MutateCampaignFeedsRequest request = new MutateCampaignFeedsRequest { CustomerId = "", Operations = { new CampaignFeedOperation(), }, PartialFailure = false, ValidateOnly = false, }; // Make the request MutateCampaignFeedsResponse response = await campaignFeedServiceClient.MutateCampaignFeedsAsync(request); // End snippet }