Example #1
0
 /// <summary>Snippet for GetKeywordPlanCampaign</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetKeywordPlanCampaign()
 {
     // Create client
     KeywordPlanCampaignServiceClient keywordPlanCampaignServiceClient = KeywordPlanCampaignServiceClient.Create();
     // Initialize request argument(s)
     string resourceName = "customers/[CUSTOMER]/keywordPlanCampaigns/[KEYWORD_PLAN_CAMPAIGN]";
     // Make the request
     KeywordPlanCampaign response = keywordPlanCampaignServiceClient.GetKeywordPlanCampaign(resourceName);
 }
 /// <summary>Snippet for GetKeywordPlanCampaign</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetKeywordPlanCampaignResourceNames()
 {
     // Create client
     KeywordPlanCampaignServiceClient keywordPlanCampaignServiceClient = KeywordPlanCampaignServiceClient.Create();
     // Initialize request argument(s)
     KeywordPlanCampaignName resourceName = KeywordPlanCampaignName.FromCustomerKeywordPlanCampaign("[CUSTOMER]", "[KEYWORD_PLAN_CAMPAIGN]");
     // Make the request
     KeywordPlanCampaign response = keywordPlanCampaignServiceClient.GetKeywordPlanCampaign(resourceName);
 }
        /// <summary>Snippet for GetKeywordPlanCampaignAsync</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 GetKeywordPlanCampaignAsync()
        {
            // Create client
            KeywordPlanCampaignServiceClient keywordPlanCampaignServiceClient = await KeywordPlanCampaignServiceClient.CreateAsync();

            // Initialize request argument(s)
            string resourceName = "customers/[CUSTOMER_ID]/keywordPlanCampaigns/[KEYWORD_PLAN_CAMPAIGN_ID]";
            // Make the request
            KeywordPlanCampaign response = await keywordPlanCampaignServiceClient.GetKeywordPlanCampaignAsync(resourceName);
        }
        /// <summary>Snippet for GetKeywordPlanCampaignAsync</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 GetKeywordPlanCampaignResourceNamesAsync()
        {
            // Create client
            KeywordPlanCampaignServiceClient keywordPlanCampaignServiceClient = await KeywordPlanCampaignServiceClient.CreateAsync();

            // Initialize request argument(s)
            KeywordPlanCampaignName resourceName = KeywordPlanCampaignName.FromCustomerKeywordPlanCampaign("[CUSTOMER_ID]", "[KEYWORD_PLAN_CAMPAIGN_ID]");
            // Make the request
            KeywordPlanCampaign response = await keywordPlanCampaignServiceClient.GetKeywordPlanCampaignAsync(resourceName);
        }
Example #5
0
 /// <summary>Snippet for GetKeywordPlanCampaign</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetKeywordPlanCampaignRequestObject()
 {
     // Create client
     KeywordPlanCampaignServiceClient keywordPlanCampaignServiceClient = KeywordPlanCampaignServiceClient.Create();
     // Initialize request argument(s)
     GetKeywordPlanCampaignRequest request = new GetKeywordPlanCampaignRequest
     {
         ResourceNameAsKeywordPlanCampaignName = KeywordPlanCampaignName.FromCustomerKeywordPlanCampaign("[CUSTOMER_ID]", "[KEYWORD_PLAN_CAMPAIGN_ID]"),
     };
     // Make the request
     KeywordPlanCampaign response = keywordPlanCampaignServiceClient.GetKeywordPlanCampaign(request);
 }
Example #6
0
 /// <summary>Snippet for MutateKeywordPlanCampaigns</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateKeywordPlanCampaigns()
 {
     // Create client
     KeywordPlanCampaignServiceClient keywordPlanCampaignServiceClient = KeywordPlanCampaignServiceClient.Create();
     // Initialize request argument(s)
     string customerId = "";
     IEnumerable <KeywordPlanCampaignOperation> operations = new KeywordPlanCampaignOperation[]
     {
         new KeywordPlanCampaignOperation(),
     };
     // Make the request
     MutateKeywordPlanCampaignsResponse response = keywordPlanCampaignServiceClient.MutateKeywordPlanCampaigns(customerId, operations);
 }
        /// <summary>Snippet for GetKeywordPlanCampaignAsync</summary>
        public async Task GetKeywordPlanCampaignAsync()
        {
            // Snippet: GetKeywordPlanCampaignAsync(string, CallSettings)
            // Additional: GetKeywordPlanCampaignAsync(string, CancellationToken)
            // Create client
            KeywordPlanCampaignServiceClient keywordPlanCampaignServiceClient = await KeywordPlanCampaignServiceClient.CreateAsync();

            // Initialize request argument(s)
            string resourceName = "customers/[CUSTOMER_ID]/keywordPlanCampaigns/[KEYWORD_PLAN_CAMPAIGN_ID]";
            // Make the request
            KeywordPlanCampaign response = await keywordPlanCampaignServiceClient.GetKeywordPlanCampaignAsync(resourceName);

            // End snippet
        }
        /// <summary>Snippet for GetKeywordPlanCampaignAsync</summary>
        public async Task GetKeywordPlanCampaignResourceNamesAsync()
        {
            // Snippet: GetKeywordPlanCampaignAsync(KeywordPlanCampaignName, CallSettings)
            // Additional: GetKeywordPlanCampaignAsync(KeywordPlanCampaignName, CancellationToken)
            // Create client
            KeywordPlanCampaignServiceClient keywordPlanCampaignServiceClient = await KeywordPlanCampaignServiceClient.CreateAsync();

            // Initialize request argument(s)
            KeywordPlanCampaignName resourceName = KeywordPlanCampaignName.FromCustomerKeywordPlanCampaign("[CUSTOMER_ID]", "[KEYWORD_PLAN_CAMPAIGN_ID]");
            // Make the request
            KeywordPlanCampaign response = await keywordPlanCampaignServiceClient.GetKeywordPlanCampaignAsync(resourceName);

            // End snippet
        }
        /// <summary>Snippet for MutateKeywordPlanCampaignsAsync</summary>
        public async Task MutateKeywordPlanCampaignsAsync()
        {
            // Snippet: MutateKeywordPlanCampaignsAsync(string, IEnumerable<KeywordPlanCampaignOperation>, CallSettings)
            // Additional: MutateKeywordPlanCampaignsAsync(string, IEnumerable<KeywordPlanCampaignOperation>, CancellationToken)
            // Create client
            KeywordPlanCampaignServiceClient keywordPlanCampaignServiceClient = await KeywordPlanCampaignServiceClient.CreateAsync();

            // Initialize request argument(s)
            string customerId = "";
            IEnumerable <KeywordPlanCampaignOperation> operations = new KeywordPlanCampaignOperation[]
            {
                new KeywordPlanCampaignOperation(),
            };
            // Make the request
            MutateKeywordPlanCampaignsResponse response = await keywordPlanCampaignServiceClient.MutateKeywordPlanCampaignsAsync(customerId, operations);

            // End snippet
        }
 /// <summary>Snippet for MutateKeywordPlanCampaigns</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateKeywordPlanCampaignsRequestObject()
 {
     // Create client
     KeywordPlanCampaignServiceClient keywordPlanCampaignServiceClient = KeywordPlanCampaignServiceClient.Create();
     // Initialize request argument(s)
     MutateKeywordPlanCampaignsRequest request = new MutateKeywordPlanCampaignsRequest
     {
         CustomerId = "",
         Operations =
         {
             new KeywordPlanCampaignOperation(),
         },
         PartialFailure = false,
         ValidateOnly   = false,
     };
     // Make the request
     MutateKeywordPlanCampaignsResponse response = keywordPlanCampaignServiceClient.MutateKeywordPlanCampaigns(request);
 }
Example #11
0
        /// <summary>
        /// Creates the campaign 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="keywordPlanResource">The keyword plan resource.</param>
        /// <returns>The newly created campaign resource.</returns>
        private string CreateKeywordPlanCampaign(GoogleAdsClient client, long customerId,
                                                 String keywordPlanResource)
        {
            // Get the KeywordPlanCampaignService.
            KeywordPlanCampaignServiceClient serviceClient = client.GetService(
                Services.V6.KeywordPlanCampaignService);

            // Create a keyword plan campaign.
            KeywordPlanCampaign campaign = new KeywordPlanCampaign()
            {
                Name               = "Keyword plan campaign #" + ExampleUtilities.GetRandomString(),
                CpcBidMicros       = 1_000_000L,
                KeywordPlanNetwork = KeywordPlanNetwork.GoogleSearch,
                KeywordPlan        = keywordPlanResource
            };

            // See https://developers.google.com/adwords/api/docs/appendix/geotargeting
            // for the list of geo target IDs.
            campaign.GeoTargets.Add(new KeywordPlanGeoTarget()
            {
                GeoTargetConstant = ResourceNames.GeoTargetConstant(2840) /* USA */
            });

            // See https://developers.google.com/adwords/api/docs/appendix/codes-formats#languages
            // for the list of language criteria IDs.
            campaign.LanguageConstants.Add(ResourceNames.LanguageConstant(1000)); /* English */

            KeywordPlanCampaignOperation operation = new KeywordPlanCampaignOperation()
            {
                Create = campaign
            };

            // Add the campaign.
            MutateKeywordPlanCampaignsResponse response =
                serviceClient.MutateKeywordPlanCampaigns(customerId.ToString(),
                                                         new KeywordPlanCampaignOperation[] { operation });

            // Display the result.
            String planCampaignResource = response.Results[0].ResourceName;

            Console.WriteLine($"Created campaign for keyword plan: {planCampaignResource}.");
            return(planCampaignResource);
        }
        /// <summary>Snippet for MutateKeywordPlanCampaignsAsync</summary>
        public async Task MutateKeywordPlanCampaignsRequestObjectAsync()
        {
            // Snippet: MutateKeywordPlanCampaignsAsync(MutateKeywordPlanCampaignsRequest, CallSettings)
            // Additional: MutateKeywordPlanCampaignsAsync(MutateKeywordPlanCampaignsRequest, CancellationToken)
            // Create client
            KeywordPlanCampaignServiceClient keywordPlanCampaignServiceClient = await KeywordPlanCampaignServiceClient.CreateAsync();

            // Initialize request argument(s)
            MutateKeywordPlanCampaignsRequest request = new MutateKeywordPlanCampaignsRequest
            {
                CustomerId = "",
                Operations =
                {
                    new KeywordPlanCampaignOperation(),
                },
                PartialFailure = false,
                ValidateOnly   = false,
            };
            // Make the request
            MutateKeywordPlanCampaignsResponse response = await keywordPlanCampaignServiceClient.MutateKeywordPlanCampaignsAsync(request);

            // End snippet
        }