Пример #1
0
        /// <summary>
        /// Creates 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>
        /// <returns>The newly created keyword plan resource.</returns>
        private string CreateKeywordPlan(GoogleAdsClient client, long customerId)
        {
            // Get the KeywordPlanService.
            KeywordPlanServiceClient serviceClient = client.GetService(
                Services.V6.KeywordPlanService);

            // Create a keyword plan for next quarter forecast.
            KeywordPlan keywordPlan = new KeywordPlan()
            {
                Name           = "Keyword plan for traffic estimate #" + ExampleUtilities.GetRandomString(),
                ForecastPeriod = new KeywordPlanForecastPeriod()
                {
                    DateInterval = KeywordPlanForecastInterval.NextQuarter
                }
            };

            KeywordPlanOperation operation = new KeywordPlanOperation()
            {
                Create = keywordPlan
            };

            // Add the keyword plan.
            MutateKeywordPlansResponse response = serviceClient.MutateKeywordPlans(
                customerId.ToString(), new KeywordPlanOperation[] { operation });

            // Display the results.
            String planResource = response.Results[0].ResourceName;

            Console.WriteLine($"Created keyword plan: {planResource}.");
            return(planResource);
        }
Пример #2
0
 /// <summary>Snippet for MutateKeywordPlans</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateKeywordPlans()
 {
     // Create client
     KeywordPlanServiceClient keywordPlanServiceClient = KeywordPlanServiceClient.Create();
     // Initialize request argument(s)
     string customerId = "";
     IEnumerable <KeywordPlanOperation> operations = new KeywordPlanOperation[]
     {
         new KeywordPlanOperation(),
     };
     // Make the request
     MutateKeywordPlansResponse response = keywordPlanServiceClient.MutateKeywordPlans(customerId, operations);
 }
Пример #3
0
        /// <summary>Snippet for MutateKeywordPlansAsync</summary>
        public async Task MutateKeywordPlansAsync()
        {
            // Snippet: MutateKeywordPlansAsync(string, IEnumerable<KeywordPlanOperation>, CallSettings)
            // Additional: MutateKeywordPlansAsync(string, IEnumerable<KeywordPlanOperation>, CancellationToken)
            // Create client
            KeywordPlanServiceClient keywordPlanServiceClient = await KeywordPlanServiceClient.CreateAsync();

            // Initialize request argument(s)
            string customerId = "";
            IEnumerable <KeywordPlanOperation> operations = new KeywordPlanOperation[]
            {
                new KeywordPlanOperation(),
            };
            // Make the request
            MutateKeywordPlansResponse response = await keywordPlanServiceClient.MutateKeywordPlansAsync(customerId, operations);

            // End snippet
        }