Example #1
0
        /// <summary>
        /// Creates campaign negative keywords for the keyword plan.
        /// </summary>
        /// <param name="client">he 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
        /// negative keyword is created.</param>
        private static void CreateKeywordPlanCampaignNegativeKeywords(GoogleAdsClient client,
                                                                      long customerId, string planCampaignResource)
        {
            // Get the KeywordPlanCampaignKeywordService.
            KeywordPlanCampaignKeywordServiceClient service = client.GetService(
                Services.V6.KeywordPlanCampaignKeywordService);

            // Create the campaign negative keyword for the keyword plan.
            KeywordPlanCampaignKeyword kpCampaignNegativeKeyword = new KeywordPlanCampaignKeyword()
            {
                KeywordPlanCampaign = planCampaignResource,
                MatchType           = KeywordMatchType.Broad,
                Text     = "moon walk",
                Negative = true
            };

            KeywordPlanCampaignKeywordOperation operation = new KeywordPlanCampaignKeywordOperation
            {
                Create = kpCampaignNegativeKeyword
            };

            // Add the campaign negative keyword.
            MutateKeywordPlanCampaignKeywordsResponse response =
                service.MutateKeywordPlanCampaignKeywords(customerId.ToString(),
                                                          new KeywordPlanCampaignKeywordOperation[] { operation });

            // Display the result.
            MutateKeywordPlanCampaignKeywordResult result = response.Results[0];

            Console.WriteLine("Created campaign negative keyword for keyword plan: " +
                              $"{result.ResourceName}.");
            return;
        }
 /// <summary>Snippet for MutateKeywordPlanCampaignKeywords</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateKeywordPlanCampaignKeywords()
 {
     // Create client
     KeywordPlanCampaignKeywordServiceClient keywordPlanCampaignKeywordServiceClient = KeywordPlanCampaignKeywordServiceClient.Create();
     // Initialize request argument(s)
     string customerId = "";
     IEnumerable <KeywordPlanCampaignKeywordOperation> operations = new KeywordPlanCampaignKeywordOperation[]
     {
         new KeywordPlanCampaignKeywordOperation(),
     };
     // Make the request
     MutateKeywordPlanCampaignKeywordsResponse response = keywordPlanCampaignKeywordServiceClient.MutateKeywordPlanCampaignKeywords(customerId, operations);
 }
Example #3
0
        /// <summary>Snippet for MutateKeywordPlanCampaignKeywordsAsync</summary>
        public async Task MutateKeywordPlanCampaignKeywordsAsync()
        {
            // Snippet: MutateKeywordPlanCampaignKeywordsAsync(string, IEnumerable<KeywordPlanCampaignKeywordOperation>, CallSettings)
            // Additional: MutateKeywordPlanCampaignKeywordsAsync(string, IEnumerable<KeywordPlanCampaignKeywordOperation>, CancellationToken)
            // Create client
            KeywordPlanCampaignKeywordServiceClient keywordPlanCampaignKeywordServiceClient = await KeywordPlanCampaignKeywordServiceClient.CreateAsync();

            // Initialize request argument(s)
            string customerId = "";
            IEnumerable <KeywordPlanCampaignKeywordOperation> operations = new KeywordPlanCampaignKeywordOperation[]
            {
                new KeywordPlanCampaignKeywordOperation(),
            };
            // Make the request
            MutateKeywordPlanCampaignKeywordsResponse response = await keywordPlanCampaignKeywordServiceClient.MutateKeywordPlanCampaignKeywordsAsync(customerId, operations);

            // End snippet
        }