/// <summary> /// Creates the ad group for the keyword plan. /// </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="planCampaignResource">The resource name of the campaign under which the /// ad group is created.</param> /// <returns>The newly created ad group resource.</returns> private string CreateKeywordPlanAdGroup(GoogleAdsClient client, long customerId, string planCampaignResource) { // Get the KeywordPlanAdGroupService. KeywordPlanAdGroupServiceClient serviceClient = client.GetService( Services.V6.KeywordPlanAdGroupService); // Create the keyword plan ad group. KeywordPlanAdGroup adGroup = new KeywordPlanAdGroup() { KeywordPlanCampaign = planCampaignResource, Name = "Keyword plan ad group #" + ExampleUtilities.GetRandomString(), CpcBidMicros = 2_500_000L }; KeywordPlanAdGroupOperation operation = new KeywordPlanAdGroupOperation() { Create = adGroup }; // Add the ad group. MutateKeywordPlanAdGroupsResponse response = serviceClient.MutateKeywordPlanAdGroups( customerId.ToString(), new KeywordPlanAdGroupOperation[] { operation }); // Display the result. String planAdGroupResource = response.Results[0].ResourceName; Console.WriteLine($"Created ad group for keyword plan: {planAdGroupResource}."); return(planAdGroupResource); }
/// <summary>Snippet for MutateKeywordPlanAdGroups</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void MutateKeywordPlanAdGroups() { // Create client KeywordPlanAdGroupServiceClient keywordPlanAdGroupServiceClient = KeywordPlanAdGroupServiceClient.Create(); // Initialize request argument(s) string customerId = ""; IEnumerable <KeywordPlanAdGroupOperation> operations = new KeywordPlanAdGroupOperation[] { new KeywordPlanAdGroupOperation(), }; // Make the request MutateKeywordPlanAdGroupsResponse response = keywordPlanAdGroupServiceClient.MutateKeywordPlanAdGroups(customerId, operations); }
/// <summary>Snippet for MutateKeywordPlanAdGroupsAsync</summary> public async Task MutateKeywordPlanAdGroupsAsync() { // Snippet: MutateKeywordPlanAdGroupsAsync(string, IEnumerable<KeywordPlanAdGroupOperation>, CallSettings) // Additional: MutateKeywordPlanAdGroupsAsync(string, IEnumerable<KeywordPlanAdGroupOperation>, CancellationToken) // Create client KeywordPlanAdGroupServiceClient keywordPlanAdGroupServiceClient = await KeywordPlanAdGroupServiceClient.CreateAsync(); // Initialize request argument(s) string customerId = ""; IEnumerable <KeywordPlanAdGroupOperation> operations = new KeywordPlanAdGroupOperation[] { new KeywordPlanAdGroupOperation(), }; // Make the request MutateKeywordPlanAdGroupsResponse response = await keywordPlanAdGroupServiceClient.MutateKeywordPlanAdGroupsAsync(customerId, operations); // End snippet }