/// <summary> /// Gets the location extension feeds. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The customer ID for which the call is made.</param> /// <returns>The list of location extension feeds.</returns> private static Feed[] GetLocationExtensionFeeds(GoogleAdsClient client, long customerId) { List <Feed> feeds = new List <Feed>(); GoogleAdsServiceClient googleAdsService = client.GetService( Services.V4.GoogleAdsService); // Create the query. string query = $"SELECT feed.resource_name, feed.status, " + $"feed.places_location_feed_data.email_address, " + $"feed.affiliate_location_feed_data.chain_ids " + $" from feed where feed.status = ENABLED"; PagedEnumerable <SearchGoogleAdsResponse, GoogleAdsRow> result = googleAdsService.Search(customerId.ToString(), query); foreach (GoogleAdsRow row in result) { // A location extension feed can be identified by checking whether the // PlacesLocationFeedData field is set (Location extensions feeds) or // AffiliateLocationFeedData field is set (Affiliate location extension feeds) Feed feed = row.Feed; if (feed.PlacesLocationFeedData != null || feed.AffiliateLocationFeedData != null) { feeds.Add(feed); } } return(feeds.ToArray()); }
/// <summary> /// Retrieves the manager link resource name of a customer client link given its resource /// name. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="managerCustomerId">The manager customer ID.</param> /// <param name="clientCustomerId">The client customer ID.</param> /// <param name="customerClientLinkResourceName">The customer client link resource /// name.</param> /// <returns>The manager link resource name.</returns> private string GetManagerLinkResourceName(GoogleAdsClient client, long managerCustomerId, long clientCustomerId, string customerClientLinkResourceName) { // Get the GoogleAdsService. GoogleAdsServiceClient googleAdsService = client.GetService(Services.V6.GoogleAdsService); // Create a client with the manager customer ID as login customer ID. client.Config.LoginCustomerId = managerCustomerId.ToString(); // Creates the query. string query = "SELECT customer_client_link.manager_link_id FROM " + "customer_client_link WHERE customer_client_link.resource_name = " + $"'{customerClientLinkResourceName}'"; // Issue a search request by specifying the page size. GoogleAdsRow result = googleAdsService.Search( managerCustomerId.ToString(), query).First(); // Gets the ID and resource name associated to the manager link found. long managerLinkId = result.CustomerManagerLink.ManagerLinkId; string managerLinkResourceName = ResourceNames.CustomerManagerLink( clientCustomerId, managerCustomerId, managerLinkId); // Prints the result. Console.WriteLine($"Retrieved the manager link of the customer client link: its ID " + $"is {managerLinkId} and its resource name is '{managerLinkResourceName}'."); // Returns the resource name of the manager link found. return(managerLinkResourceName); }
/// <summary> /// Runs the code example. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The Google Ads customer ID for which the call is made.</param> public void Run(GoogleAdsClient client, long customerId) { // Get the GoogleAdsServiceClient. GoogleAdsServiceClient googleAdsService = client.GetService( Services.V2.GoogleAdsService); // Construct a GAQL query which will retrieve AccountBudgetProposals. String searchQuery = @"SELECT account_budget_proposal.id, account_budget_proposal.account_budget, account_budget_proposal.billing_setup, account_budget_proposal.status, account_budget_proposal.proposed_name, account_budget_proposal.proposed_notes, account_budget_proposal.proposed_purchase_order_number, account_budget_proposal.proposal_type, account_budget_proposal.approval_date_time, account_budget_proposal.creation_date_time FROM account_budget_proposal"; // Creates a request that will retrieve all account budget proposals using pages of the // specified page size. SearchGoogleAdsRequest request = new SearchGoogleAdsRequest() { PageSize = PAGE_SIZE, Query = searchQuery, CustomerId = customerId.ToString() }; try { // Issues the search request. PagedEnumerable <SearchGoogleAdsResponse, GoogleAdsRow> searchPagedResponse = googleAdsService.Search(request); // Iterates over all rows in all pages and prints the requested field values for // the account budget in each row. foreach (GoogleAdsRow googleAdsRow in searchPagedResponse) { AccountBudgetProposal proposal = googleAdsRow.AccountBudgetProposal; Console.WriteLine($"Account budget proposal with ID '{proposal.Id}' " + $"status '{proposal.Status}', account_budget '{proposal.AccountBudget}' " + $"billing_setup '{proposal.BillingSetup}', " + $"proposed_name '{proposal.ProposedName}', " + $"proposed_notes '{proposal.ProposedNotes}', " + $"proposed_po_number '{proposal.ProposedPurchaseOrderNumber}', " + $"proposal_type '{proposal.ProposalType}', " + $"approval_date_time '{proposal.ApprovalDateTime}', " + $"creation_date_time '{proposal.CreationDateTime}'."); } } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); } }
/// <summary> /// Fetches the draft campaign associated with a campaign draft. /// </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="draftResourceName">Resource name of the draft.</param> /// <returns></returns> private static string FetchDraftCampaign(GoogleAdsClient client, long customerId, string draftResourceName) { // Get the GoogleAdsService. GoogleAdsServiceClient googleAdsService = client.GetService(Services.V1.GoogleAdsService); // Once the draft is created, you can modify the draft campaign as if it were // a real campaign. For example, you may add criteria, adjust bids, or even // include additional ads. Adding a criterion is shown here. string query = $@" SELECT campaign_draft.draft_campaign FROM campaign_draft WHERE campaign_draft.resource_name = '{draftResourceName}'"; // Get the draft campaign resource name. string draftCampaignResourceName = googleAdsService.Search( customerId.ToString(), query).First().CampaignDraft.DraftCampaign; return(draftCampaignResourceName); }
/// <summary> /// Fetches an experiment and display its details. /// </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="experimentResourceName">Resource name of the experiment.</param> /// <returns></returns> private static void DisplayExperimentDetails(GoogleAdsClient client, long customerId, string experimentResourceName) { // Get the GoogleAdsService. GoogleAdsServiceClient googleAdsService = client.GetService(Services.V3.GoogleAdsService); // Once the draft is created, you can modify the draft campaign as if it were // a real campaign. For example, you may add criteria, adjust bids, or even // include additional ads. Adding a criterion is shown here. string query = $@" SELECT campaign_experiment.experiment_campaign FROM campaign_experiment WHERE campaign_experiment.resource_name = '{experimentResourceName}'"; // Get the expriment campaign resource name. string experimentCampaignResourceName = googleAdsService.Search( customerId.ToString(), query).First().CampaignExperiment.ExperimentCampaign; Console.WriteLine($"Experiment campaign with resource ID =" + $" '{experimentCampaignResourceName}' finished creating."); }
/// <summary> /// Retrieves all the attributes for a feed and returns them in a map using the /// attribute names as keys. /// </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="feedResourceName">The resource name of the feed.</param> /// <returns>The attributes of the feed.</returns> private Dictionary <string, FeedAttribute> GetFeedAttributes(GoogleAdsClient client, long customerId, string feedResourceName) { // Get the GoogleAdsServiceClient. GoogleAdsServiceClient googleAdsService = client.GetService(Services.V5.GoogleAdsService); string query = $"SELECT feed.attributes, feed.name FROM feed WHERE " + $"feed.resource_name = '{feedResourceName}'"; SearchGoogleAdsRequest request = new SearchGoogleAdsRequest() { CustomerId = customerId.ToString(), Query = query }; Dictionary <string, FeedAttribute> feedAttributes = new Dictionary <string, FeedAttribute>(); Feed feed = googleAdsService.Search(request).First().Feed; Console.WriteLine($"Found the following attributes for feed with name '{feed.Name}'"); foreach (FeedAttribute feedAttribute in feed.Attributes) { Console.WriteLine($"\t'{feedAttribute.Name}' with id {feedAttribute.Id} and " + $"type '{feedAttribute.Type}'"); feedAttributes[feedAttribute.Name] = feedAttribute; } return(feedAttributes); }
/// <summary> /// Retrieves details about a feed. The initial query retrieves the FeedAttributes, /// or columns, of the feed. Each FeedAttribute will also include the FeedAttributeId, /// which will be used in a subsequent step. The example then inserts a new key, value /// pair into a map for each FeedAttribute, which is the return value of the method. /// The keys are the placeholder types that the columns will be. The values are the /// FeedAttributes. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The Google Ads customer ID for which the flights feed is /// added.</param> /// <param name="feedResourceName">The resource name of the feed.</param> /// <returns> /// A Map containing the FlightPlaceholderField and FeedAttribute. /// </returns> public Dictionary <FlightPlaceholderField, FeedAttribute> GetFeed( GoogleAdsClient client, long customerId, string feedResourceName) { // Get the GoogleAdsService. GoogleAdsServiceClient googleAdsService = client.GetService( Services.V6.GoogleAdsService); // Constructs the query. string query = $"SELECT feed.attributes FROM feed WHERE feed.resource_name = " + $"'{feedResourceName}'"; // Constructs the request. SearchGoogleAdsRequest request = new SearchGoogleAdsRequest() { CustomerId = customerId.ToString(), Query = query }; // Issues the search request and get the first result, since we only need the // single feed item we created previously. GoogleAdsRow googleAdsRow = googleAdsService.Search(request).First(); // Gets the attributes list from the feed and creates a map with keys of each attribute and // values of each corresponding ID. Dictionary <FlightPlaceholderField, FeedAttribute> feedAttributes = new Dictionary <FlightPlaceholderField, FeedAttribute>(); // Loops through the feed attributes to populate the map. foreach (FeedAttribute feedAttribute in googleAdsRow.Feed.Attributes) { switch (feedAttribute.Name) { case "Flight Description": feedAttributes[FlightPlaceholderField.FlightDescription] = feedAttribute; break; case "Destination ID": feedAttributes[FlightPlaceholderField.DestinationId] = feedAttribute; break; case "Flight Price": feedAttributes[FlightPlaceholderField.FlightPrice] = feedAttribute; break; case "Flight Sale Price": feedAttributes[FlightPlaceholderField.FlightSalePrice] = feedAttribute; break; case "Final URLs": feedAttributes[FlightPlaceholderField.FinalUrls] = feedAttribute; break; // The full list of FlightPlaceholderFields can be found here // https://developers.google.com/google-ads/api/reference/rpc/latest/FlightPlaceholderFieldEnum.FlightPlaceholderField default: throw new Exception("Invalid attribute name."); } } return(feedAttributes); }
private static CustomerFeed[] GetLocationExtensionCustomerFeeds(GoogleAdsClient client, long customerId) { List <CustomerFeed> customerFeeds = new List <CustomerFeed>(); GoogleAdsServiceClient googleAdsService = client.GetService( Services.V4.GoogleAdsService); // Create the query. A location extension customer feed can be identified by filtering // for placeholder_types=LOCATION (location extension feeds) or // placeholder_types =AFFILIATE_LOCATION (affiliate location extension feeds) string query = $"SELECT customer_feed.resource_name, customer_feed.feed, " + $"customer_feed.status, customer_feed.matching_function.function_string from " + $"customer_feed " + $"WHERE customer_feed.placeholder_types CONTAINS " + $"ANY(LOCATION, AFFILIATE_LOCATION) and customer_feed.status=ENABLED"; PagedEnumerable <SearchGoogleAdsResponse, GoogleAdsRow> result = googleAdsService.Search(customerId.ToString(), query); foreach (GoogleAdsRow row in result) { customerFeeds.Add(row.CustomerFeed); } return(customerFeeds.ToArray()); }
// [END add_performance_max_retail_campaign_8] // [START add_performance_max_retail_campaign_9] /// <summary> /// Retrieves the list of customer conversion goals. /// </summary> /// <param name="client">The Google Ads Client.</param> /// <param name="customerId">The customer's id.</param> /// <returns>A list customer conversion goals.</returns> private List <CustomerConversionGoal> GetCustomerConversionGoals( GoogleAdsClient client, long customerId) { // Get the GoogleAdsService. GoogleAdsServiceClient googleAdsServiceClient = client.GetService(Services.V10.GoogleAdsService); List <CustomerConversionGoal> conversionGoals = new List <CustomerConversionGoal>(); SearchGoogleAdsRequest request = new SearchGoogleAdsRequest() { CustomerId = customerId.ToString(), PageSize = 10000, Query = @"SELECT customer_conversion_goal.category, customer_conversion_goal.origin FROM customer_conversion_goal" }; // The number of conversion goals is typically less than 50 so we use // GoogleAdsService.search instead of search_stream. PagedEnumerable <SearchGoogleAdsResponse, GoogleAdsRow> searchPagedResponse = googleAdsServiceClient.Search(request); // Iterate over the results and build the list of conversion goals. foreach (GoogleAdsRow row in searchPagedResponse) { conversionGoals.Add(row.CustomerConversionGoal); } return(conversionGoals); }
/// <summary> /// Runs the code example. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The Google Ads customer Id.</param> public void Run(GoogleAdsClient client, long customerId) { // Get the GoogleAdsService. GoogleAdsServiceClient googleAdsService = client.GetService( Services.V2.GoogleAdsService); // Create the query. string query = $@"SELECT campaign.id, campaign.name, ad_group.id, ad_group.name, ad_group_criterion.criterion_id, ad_group_criterion.keyword.text, ad_group_criterion.keyword.match_type, metrics.impressions, metrics.clicks, metrics.cost_micros, metrics.video_quartile_25_rate FROM keyword_view WHERE segments.date DURING LAST_7_DAYS AND campaign.advertising_channel_type = 'SEARCH' AND ad_group.status = 'ENABLED' AND ad_group_criterion.status IN ('ENABLED','PAUSED') ORDER BY metrics.impressions DESC LIMIT 50"; try { // Issue a search request. PagedEnumerable <SearchGoogleAdsResponse, GoogleAdsRow> result = googleAdsService.Search(customerId.ToString(), query); // Display the results. foreach (GoogleAdsRow criterionRow in result) { Console.WriteLine( $"Keyword with text '{criterionRow.AdGroupCriterion.Keyword.Text}', " + $" match type '{criterionRow.AdGroupCriterion.Keyword.MatchType}' and " + $"ID {criterionRow.AdGroupCriterion.CriterionId} " + $"in ad group '{criterionRow.AdGroup.Name}' with " + $"ID {criterionRow.AdGroup.Id} " + $"in campaign '{criterionRow.Campaign.Name}' " + $"with ID {criterionRow.Campaign.Id} " + $"had {criterionRow.Metrics.Impressions.ToString()} impressions, " + $"{criterionRow.Metrics.Clicks} clicks, and " + $"{criterionRow.Metrics.CostMicros} cost (in micros)" + "during the last 7 days."); } } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); } }
/// <summary> /// Runs the code example. /// </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="adGroupId">Optional: ID of the ad group to restrict search to.</param> public void Run(GoogleAdsClient client, long customerId, long?adGroupId) { // Get the GoogleAdsService. GoogleAdsServiceClient googleAdsService = client.GetService( Services.V3.GoogleAdsService); string searchQuery = $@"SELECT ad_group.id, ad_group_ad.ad.id, ad_group_ad.ad.expanded_text_ad.headline_part1, ad_group_ad.ad.expanded_text_ad.headline_part2, ad_group_ad.status FROM ad_group_ad WHERE ad_group_ad.ad.type = EXPANDED_TEXT_AD "; if (adGroupId != null) { searchQuery += $" AND ad_group.id = {adGroupId}"; } // Create a request that will retrieve all ads using pages of the specified page size. SearchGoogleAdsRequest request = new SearchGoogleAdsRequest() { CustomerId = customerId.ToString(), PageSize = PAGE_SIZE, Query = searchQuery }; try { // Issue the search request. PagedEnumerable <SearchGoogleAdsResponse, GoogleAdsRow> searchPagedResponse = googleAdsService.Search(request); // Iterate over all rows in all pages and prints the requested field values for // the ad in each row. foreach (GoogleAdsRow googleAdsRow in searchPagedResponse) { Ad ad = googleAdsRow.AdGroupAd.Ad; ExpandedTextAdInfo expandedTextAdInfo = ad.ExpandedTextAd; Console.WriteLine("Expanded text ad with ID {0}, status '{1}', and headline " + "'{2} - {3}' was found in ad group with ID {4}.", ad.Id, googleAdsRow.AdGroupAd.Status, expandedTextAdInfo.HeadlinePart1, expandedTextAdInfo.HeadlinePart2, googleAdsRow.AdGroup.Id); } } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }
/// <summary> /// Runs the code example. /// </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="adGroupId">The ad group ID for which ad group bid modiifers will /// be retrieved.</param> public void Run(GoogleAdsClient client, long customerId, long?adGroupId) { // Get the GoogleAdsService. GoogleAdsServiceClient googleAdsService = client.GetService(Services.V4.GoogleAdsService); string searchQuery = "SELECT ad_group.id, ad_group_bid_modifier.criterion_id, " + "ad_group_bid_modifier.bid_modifier, ad_group_bid_modifier.device.type, " + "campaign.id FROM ad_group_bid_modifier"; if (adGroupId != null) { searchQuery += $" WHERE ad_group.id = {adGroupId}"; } // Creates a request that will retrieve ad group bid modifiers using pages of the // specified page size. SearchGoogleAdsRequest request = new SearchGoogleAdsRequest() { CustomerId = customerId.ToString(), Query = searchQuery, PageSize = PAGE_SIZE }; try { // Issue the search request. PagedEnumerable <SearchGoogleAdsResponse, GoogleAdsRow> searchPagedResponse = googleAdsService.Search(request); // Iterates over all rows in all pages and prints the requested field values for // the ad group bid modifiers in each row. foreach (GoogleAdsRow googleAdsRow in searchPagedResponse) { AdGroupBidModifier adGroupBidModifier = googleAdsRow.AdGroupBidModifier; AdGroup adGroup = googleAdsRow.AdGroup; Campaign campaign = googleAdsRow.Campaign; Console.WriteLine("Ad group bid modifier with criterion ID {0}, bid " + "modifier value {1:0.00}, device type {2} was found in an ad group " + "with ID {3} of campaign ID {4}.", adGroupBidModifier.CriterionId, adGroupBidModifier.BidModifier, adGroupBidModifier.Device.Type, adGroup.Id, campaign.Id); } } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }
/// <summary> /// Runs the code example. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The Google Ads customer ID for which the call is made.</param> public void Run(GoogleAdsClient client, long customerId) { // Get the GoogleAdsService. GoogleAdsServiceClient googleAdsService = client.GetService( Services.V3.GoogleAdsService); // Creates a query that retrieves hotel-ads statistics for each campaign and ad group. // Returned statistics will be segmented by the check-in day of week and length of // stay. String query = $@"SELECT campaign.id, campaign.advertising_channel_type, ad_group.id, ad_group.status, metrics.impressions, metrics.hotel_average_lead_value_micros, segments.hotel_check_in_day_of_week, segments.hotel_length_of_stay FROM hotel_performance_view WHERE segments.date DURING LAST_7_DAYS AND campaign.advertising_channel_type = 'HOTEL' AND ad_group.status = 'ENABLED' ORDER BY metrics.impressions DESC LIMIT 50"; try { // Issue a search request. PagedEnumerable <SearchGoogleAdsResponse, GoogleAdsRow> result = googleAdsService.Search(customerId.ToString(), query); // Display the results. foreach (GoogleAdsRow row in result) { Console.WriteLine( $"Ad group ID {row.AdGroup.Id} in campaign ID {row.Campaign.Id} " + $"with hotel check-in on {row.Segments.HotelCheckInDayOfWeek} and " + $"{row.Segments.HotelLengthOfStay} day(s) of stay had " + $"{row.Metrics.Impressions} impression(s) and " + $"{row.Metrics.HotelAverageLeadValueMicros:0.00} average lead value " + "(in micros) during the last 7 days."); } } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }
/// <summary> /// Runs the code example. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The customer ID for which the call is made.</param> public void Run(GoogleAdsClient client, long customerId) { // Get the GoogleAdsServiceClient. GoogleAdsServiceClient googleAdsService = client.GetService(Services.V3.GoogleAdsService); // Creates the search query. string searchQuery = "SELECT asset.name, asset.image_asset.file_size, " + "asset.image_asset.full_size.width_pixels, " + "asset.image_asset.full_size.height_pixels, " + "asset.image_asset.full_size.url FROM asset WHERE asset.type = 'IMAGE'"; // Creates the request. SearchGoogleAdsRequest request = new SearchGoogleAdsRequest() { CustomerId = customerId.ToString(), Query = searchQuery }; try { // Issues the search request and prints the results. int count = 0; foreach (GoogleAdsRow row in googleAdsService.Search(request)) { Asset asset = row.Asset; ImageAsset imageAsset = asset.ImageAsset; // Displays the results. Console.WriteLine($"Image with name '{asset.Name}', file size " + $"{imageAsset.FileSize} bytes, width {imageAsset.FullSize.WidthPixels}px," + $" height {imageAsset.FullSize.HeightPixels}px, and url " + $"'{imageAsset.FullSize.Url}' found."); count++; } if (count == 0) { // Displays a response if no images are found. if (count == 0) { Console.WriteLine("No image assets found."); } } } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }
/// <summary> /// Runs the code example. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The Google Ads customer ID for which the call is made.</param> public void Run(GoogleAdsClient client, long customerId) { // Get the GoogleAdsService. GoogleAdsServiceClient googleAdsService = client.GetService( Services.V4.GoogleAdsService); string searchQuery = "SELECT change_status.resource_name, " + "change_status.last_change_date_time, change_status.resource_type, " + "change_status.campaign, change_status.ad_group, change_status.resource_status, " + "change_status.ad_group_ad, change_status.ad_group_criterion, " + "change_status.campaign_criterion FROM change_status " + "WHERE change_status.last_change_date_time DURING LAST_7_DAYS " + "ORDER BY change_status.last_change_date_time"; // Create a request that will retrieve all changes using pages of the specified // page size. SearchGoogleAdsRequest request = new SearchGoogleAdsRequest() { PageSize = PAGE_SIZE, Query = searchQuery, CustomerId = customerId.ToString() }; try { // Issue the search request. PagedEnumerable <SearchGoogleAdsResponse, GoogleAdsRow> searchPagedResponse = googleAdsService.Search(request); // Iterate over all rows in all pages and prints the requested field values for the // campaign in each row. foreach (GoogleAdsRow googleAdsRow in searchPagedResponse) { Console.WriteLine("Last change: {0}, Resource type: {1}, " + "Resource name: {2}, Resource status: {3}, Specific resource name: {4}", googleAdsRow.ChangeStatus.LastChangeDateTime, googleAdsRow.ChangeStatus.ResourceType, googleAdsRow.ChangeStatus.ResourceName, googleAdsRow.ChangeStatus.ResourceStatus, SpecificResourceName(googleAdsRow.ChangeStatus.ResourceType, googleAdsRow)); } } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }
/// <summary>Snippet for Search</summary> public void SearchRequestObject() { // Snippet: Search(SearchGoogleAdsRequest, CallSettings) // Create client GoogleAdsServiceClient googleAdsServiceClient = GoogleAdsServiceClient.Create(); // Initialize request argument(s) SearchGoogleAdsRequest request = new SearchGoogleAdsRequest { CustomerId = "", Query = "", ValidateOnly = false, ReturnTotalResultsCount = false, SummaryRowSetting = SummaryRowSettingEnum.Types.SummaryRowSetting.Unspecified, }; // Make the request PagedEnumerable <SearchGoogleAdsResponse, GoogleAdsRow> response = googleAdsServiceClient.Search(request); // Iterate over all response items, lazily performing RPCs as required foreach (GoogleAdsRow item in response) { // Do something with each item Console.WriteLine(item); } // Or iterate over pages (of server-defined size), performing one RPC per page foreach (SearchGoogleAdsResponse page in response.AsRawResponses()) { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (GoogleAdsRow item in page) { // Do something with each item Console.WriteLine(item); } } // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required int pageSize = 10; Page <GoogleAdsRow> singlePage = response.ReadPage(pageSize); // Do something with the page of items Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); foreach (GoogleAdsRow item in singlePage) { // Do something with each item Console.WriteLine(item); } // Store the pageToken, for when the next page is required. string nextPageToken = singlePage.NextPageToken; // End snippet }
/// <summary> /// Runs the code example. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The Google Ads customer ID for which the call is made.</param> public void Run(GoogleAdsClient client, long customerId) { // Get the GoogleAdsService. GoogleAdsServiceClient googleAdsService = client.GetService( Services.V1.GoogleAdsService); // Create a request that will retrieve all campaigns using pages of the specified // page size. SearchGoogleAdsRequest request = new SearchGoogleAdsRequest() { PageSize = PAGE_SIZE, Query = @"SELECT campaign.id, campaign.name, campaign.network_settings.target_content_network FROM campaign ORDER BY campaign.id", CustomerId = customerId.ToString() }; try { // Issue the search request. PagedEnumerable <SearchGoogleAdsResponse, GoogleAdsRow> searchPagedResponse = googleAdsService.Search(request); foreach (SearchGoogleAdsResponse response in searchPagedResponse.AsRawResponses()) { Console.WriteLine(response.FieldMask.Paths); foreach (GoogleAdsRow googleAdsRow in response.Results) { Console.WriteLine("Campaign with ID {0} and name '{1}' was found.", googleAdsRow.Campaign.Id, googleAdsRow.Campaign.Name); } } // Iterate over all rows in all pages and prints the requested field values for the // campaign in each row. foreach (GoogleAdsRow googleAdsRow in searchPagedResponse) { Console.WriteLine("Campaign with ID {0} and name '{1}' was found.", googleAdsRow.Campaign.Id, googleAdsRow.Campaign.Name); } } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); } }
/// <summary> /// Runs the code example. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The customer ID for which the call is made.</param> public void Run(GoogleAdsClient client, long customerId) { // Get the GoogleAdsServiceClient. GoogleAdsServiceClient googleAdsService = client.GetService(Services.V6.GoogleAdsService); // Creates the search query. string searchQuery = "SELECT asset.name, asset.image_asset.file_size, " + "asset.image_asset.full_size.width_pixels, " + "asset.image_asset.full_size.height_pixels, " + "asset.image_asset.full_size.url FROM asset WHERE asset.type = 'IMAGE'"; // Creates the request. SearchGoogleAdsRequest request = new SearchGoogleAdsRequest() { CustomerId = customerId.ToString(), Query = searchQuery, ReturnTotalResultsCount = true }; try { // Issue the search request. PagedEnumerable <SearchGoogleAdsResponse, GoogleAdsRow> searchPagedResponse = googleAdsService.Search(request); long totalImageAssetCount = searchPagedResponse.AsRawResponses() .First().TotalResultsCount; foreach (GoogleAdsRow row in searchPagedResponse) { Asset asset = row.Asset; ImageAsset imageAsset = asset.ImageAsset; // Displays the results. Console.WriteLine($"Image with name '{asset.Name}', file size " + $"{imageAsset.FileSize} bytes, width {imageAsset.FullSize.WidthPixels}px," + $" height {imageAsset.FullSize.HeightPixels}px, and url " + $"'{imageAsset.FullSize.Url}' found."); } Console.WriteLine($"Total image assets found: {totalImageAssetCount}"); } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }
/// <summary> /// Runs the code example. /// </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="campaignId">ID of the campaign to from which targeting criteria are /// retrieved.</param> public void Run(GoogleAdsClient client, long customerId, long campaignId) { // Get the GoogleAdsService. GoogleAdsServiceClient googleAdsService = client.GetService( Services.V5.GoogleAdsService); // Create the query. string query = $@"SELECT campaign.id, campaign_criterion.campaign, campaign_criterion.criterion_id, campaign_criterion.negative, campaign_criterion.keyword.text, campaign_criterion.keyword.match_type FROM campaign_criterion WHERE campaign.id = {campaignId}"; try { // Issue a search request. PagedEnumerable <SearchGoogleAdsResponse, GoogleAdsRow> result = googleAdsService.Search(customerId.ToString(), query); // Display the results. foreach (GoogleAdsRow criterionRow in result) { CampaignCriterion criterion = criterionRow.CampaignCriterion; Console.Write($"Campaign criterion with id = '{criterion.CriterionId}' " + "was retrieved:"); if (criterion.Negative) { Console.Write("Negative "); } switch (criterion.CriterionCase) { case CriterionOneofCase.Keyword: Console.Write($"Keyword with text '{criterion.Keyword.Text}' "); Console.WriteLine($"and match type {criterion.Keyword.MatchType}."); break; default: Console.WriteLine("Not a Keyword!"); break; } } } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }
/// <summary> /// Gets a list of google ads rows. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="query">The query to execute.</param> /// <returns>The list of google ads rows.</returns> internal static IEnumerable <GoogleAdsRow> GetGoogleAdsRows(GoogleAdsClient client, string query) { GoogleAdsServiceClient googleAdsService = client.GetService( Services.V6.GoogleAdsService); SearchGoogleAdsRequest request = new SearchGoogleAdsRequest() { Query = query, CustomerId = client.Config.ClientCustomerId.ToString() }; return(googleAdsService.Search(request)); }
// [END add_shopping_product_listing_group_tree] /// <summary> /// Removes all the ad group criteria that define the existing listing group tree for an /// ad group. Returns without an error if all listing group criterion are successfully /// removed. /// </summary> /// <param name="client">The Google Ads API client..</param> /// <param name="customerId">The client customer ID.</param> /// <param name="adGroupId">The ID of the ad group that the new listing group tree will /// be removed from.</param> /// <exception cref="GoogleAdsException">Thrown if an API request failed with one or more /// service errors.</exception> private void RemoveListingGroupTree(GoogleAdsClient client, long customerId, long adGroupId) { // Get the GoogleAdsService. GoogleAdsServiceClient googleAdsService = client.GetService( Services.V10.GoogleAdsService); // Get the AdGroupCriterionService. AdGroupCriterionServiceClient adGroupCriterionService = client.GetService(Services.V10.AdGroupCriterionService); String searchQuery = "SELECT ad_group_criterion.resource_name FROM " + "ad_group_criterion WHERE ad_group_criterion.type = LISTING_GROUP AND " + "ad_group_criterion.listing_group.parent_ad_group_criterion IS NULL " + $"AND ad_group.id = {adGroupId}"; // Creates a request that will retrieve all listing groups where the parent ad group // criterion is NULL (and hence the root node in the tree) for a given ad group ID. SearchGoogleAdsRequest request = new SearchGoogleAdsRequest() { CustomerId = customerId.ToString(), PageSize = PAGE_SIZE, Query = searchQuery }; // Issues the search request. GoogleAdsRow googleAdsRow = googleAdsService.Search(request).FirstOrDefault(); if (googleAdsRow == null) { return; } AdGroupCriterion adGroupCriterion = googleAdsRow.AdGroupCriterion; Console.WriteLine("Found ad group criterion with the resource name: '{0}'.", adGroupCriterion.ResourceName); AdGroupCriterionOperation operation = new AdGroupCriterionOperation() { Remove = adGroupCriterion.ResourceName }; MutateAdGroupCriteriaResponse response = adGroupCriterionService.MutateAdGroupCriteria( customerId.ToString(), new AdGroupCriterionOperation[] { operation }); Console.WriteLine($"Removed {response.Results.Count}."); }
/// <summary> /// Sets the starting and ending date times for the new billing setup. Queries the /// customer's account to see if there are any approved billing setups. If there are any, /// the new billing setup starting date time is set to one day after the last. If not, the /// billing setup is set to start immediately. The ending date is set to one day after the /// starting date time. /// </summary> /// <param name="googleAdsService">The Google Ads service client.</param> /// <param name="customerId">The Google Ads customer ID for which the call is made.</param> /// <param name="billingSetup">The instance of BillingSetup whose starting date time will /// be set.</param> private void SetBillingSetupStartDateTime(GoogleAdsServiceClient googleAdsService, long customerId, BillingSetup billingSetup) { // The query to search existing approved billing setups in the end date time descending // order. // See GetBillingSetup.cs for a more detailed example of requesting billing setup // information. string query = @" SELECT billing_setup.end_date_time FROM billing_setup WHERE billing_setup.status = 'APPROVED' ORDER BY billing_setup.end_date_time DESC LIMIT 1"; // Issues a search request. PagedEnumerable <SearchGoogleAdsResponse, GoogleAdsRow> searchResponse = googleAdsService.Search(customerId.ToString(), query); if (searchResponse.Any()) { // Retrieves the ending date time of the last billing setup. string lastEndingDateTimeString = searchResponse.First().BillingSetup.EndDateTime; // A null ending date time indicates that the current billing setup is set to run // indefinitely. Billing setups cannot overlap, so throw an exception in this case. if (lastEndingDateTimeString == null) { throw new Exception("Cannot set starting and ending date times for " + "the new billing setup; the latest existing billing " + "setup is set to run indefinitely."); } DateTime lastEndingDateTime = DateTime.Parse(lastEndingDateTimeString); // Sets the new billing setup to start one day after the ending date time. billingSetup.StartDateTime = lastEndingDateTime.AddDays(1).ToString("yyyy-MM-dd"); // Sets the new billing setup to end one day after the starting date time. billingSetup.EndDateTime = lastEndingDateTime.AddDays(2).ToString("yyyy-MM-dd"); } else { // Otherwise, the only acceptable start time is TimeType.Now. billingSetup.StartTimeType = TimeType.Now; // Sets the new billing setup to end tomorrow. billingSetup.EndDateTime = DateTime.Today.AddDays(1).ToString("yyyy-MM-dd"); } }
// [END set_custom_client_timeouts] /// <summary> /// Makes an unary call using a custom client timeout. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The customer ID for which the call is made.</param> // [START set_custom_client_timeouts_1] private void MakeUnaryCall(GoogleAdsClient client, long customerId) { StringWriter writer = new StringWriter(); // Set a custom timeout. CallSettings callSettings = CallSettings.FromExpiration( Expiration.FromTimeout(TimeSpan.FromMilliseconds(CLIENT_TIMEOUT_MILLIS))); try { // Get the GoogleAdsService. GoogleAdsServiceClient googleAdsService = client.GetService( Services.V10.GoogleAdsService); string query = "SELECT campaign.id FROM campaign"; SearchGoogleAdsRequest request = new SearchGoogleAdsRequest() { CustomerId = customerId.ToString(), Query = query }; // Issue a search request. var googleAdsRows = googleAdsService.Search(request, callSettings); foreach (GoogleAdsRow googleAdsRow in googleAdsRows) { // Iterates over all rows in all messages and collects the campaign IDs. writer.WriteLine(googleAdsRow.Campaign.Id); } Console.WriteLine("The search paged call completed before the timeout."); } catch (GoogleAdsException ex) { if (ex.StatusCode == StatusCode.DeadlineExceeded) { Console.WriteLine("The search paged call did not complete before the timeout."); } else { throw; } } finally { Console.WriteLine($"All campaign IDs retrieved: {writer}."); } }
// [START navigate_search_result_pages_caching_tokens] /// <summary> /// Fetches and prints the results of a page of a search using a cache of page tokens. /// </summary> /// <param name="googleAdsService">The Google Ads API Service client.</param> /// <param name="request">The request.</param> /// <param name="pageNumber">The number of the page to fetch and print results for.</param> /// <param name="pageTokens">The cache of page tokens to use and update.</param> /// <returns></returns> private static void FetchAndPrintPageResults(GoogleAdsServiceClient googleAdsService, SearchGoogleAdsRequest request, int pageNumber, Dictionary <int, string> pageTokens) { int currentPageNumber = pageNumber; // There is no need to fetch the pages we already know the page tokens for. if (pageTokens.ContainsKey(pageNumber - 1)) { Console.WriteLine("The token of the requested page was cached, we will use it " + "to get the results."); currentPageNumber = pageNumber; } else { Console.WriteLine("The token of the requested page was never cached, we will " + $"use the closest page we know the token for (page #{pageNumber}) and " + $"sequentially get pages from there."); currentPageNumber = pageNumber; while (!pageTokens.ContainsKey(currentPageNumber)) { currentPageNumber--; } } SearchGoogleAdsResponse response = null; // Fetches next pages in sequence and caches their tokens until the requested page // results are returned. while (currentPageNumber <= pageNumber) { // Fetches the next page. Console.WriteLine($"Fetching page #{currentPageNumber}..."); request.PageToken = pageTokens[currentPageNumber - 1]; response = googleAdsService.Search(request) .AsRawResponses().First(); CacheNextPageToken(pageTokens, response, currentPageNumber); currentPageNumber++; } // Prints the results of the requested page. Console.WriteLine($"Printing results found for the page #{pageNumber}"); foreach (GoogleAdsRow row in response.Results) { Campaign c = row.Campaign; Console.WriteLine($" - Campaign with ID {c.Id} and name '{c.Name}'"); } }
/// <summary> /// Retrieves details about a feed. /// </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="feedResourceName">The feed resource name.</param> /// <returns></returns> /// <exception cref="NotImplementedException"></exception> private Dictionary <DsaPageFeedCriterionField, FeedAttribute> GetFeed( GoogleAdsClient client, long customerId, string feedResourceName) { // Get the GoogleAdsService. GoogleAdsServiceClient googleAdsService = client.GetService( Services.V3.GoogleAdsService); // Construct the query. String query = $"SELECT feed.attributes FROM feed WHERE feed.resource_name" + $" = '{feedResourceName}'"; // Construct the request. SearchGoogleAdsRequest request = new SearchGoogleAdsRequest() { CustomerId = customerId.ToString(), Query = query }; // Issue the search request. Feed feed = googleAdsService.Search(customerId.ToString(), query).First().Feed; Dictionary <DsaPageFeedCriterionField, FeedAttribute> retval = new Dictionary <DsaPageFeedCriterionField, FeedAttribute>(); foreach (FeedAttribute attribute in feed.Attributes) { DsaPageFeedCriterionField key; switch (attribute.Name) { case "Page URL": key = DsaPageFeedCriterionField.PageUrl; break; case "Label": key = DsaPageFeedCriterionField.Label; break; default: throw new Exception("Unable to map attribute name to DSA page feed" + " criterion."); } retval[key] = attribute; } return(retval); }
/// <summary>Snippet for Search</summary> public void Search() { // Snippet: Search(string, string, string, int?, CallSettings) // Create client GoogleAdsServiceClient googleAdsServiceClient = GoogleAdsServiceClient.Create(); // Initialize request argument(s) string customerId = ""; string query = ""; // Make the request PagedEnumerable <SearchGoogleAdsResponse, GoogleAdsRow> response = googleAdsServiceClient.Search(customerId, query); // Iterate over all response items, lazily performing RPCs as required foreach (GoogleAdsRow item in response) { // Do something with each item Console.WriteLine(item); } // Or iterate over pages (of server-defined size), performing one RPC per page foreach (SearchGoogleAdsResponse page in response.AsRawResponses()) { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (GoogleAdsRow item in page) { // Do something with each item Console.WriteLine(item); } } // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required int pageSize = 10; Page <GoogleAdsRow> singlePage = response.ReadPage(pageSize); // Do something with the page of items Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); foreach (GoogleAdsRow item in singlePage) { // Do something with each item Console.WriteLine(item); } // Store the pageToken, for when the next page is required. string nextPageToken = singlePage.NextPageToken; // End snippet }
/// <summary> /// Runs the code example. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The customer ID for which the call is made.</param> public void Run(GoogleAdsClient client, long customerId) { // Get the GoogleAdsServiceClient. GoogleAdsServiceClient googleAdsService = client.GetService(Services.V6.GoogleAdsService); // Creates a request that will retrieve all video and image files. SearchGoogleAdsRequest request = new SearchGoogleAdsRequest() { CustomerId = customerId.ToString(), Query = "SELECT media_file.id, media_file.name, media_file.type " + "FROM media_file where media_file.type in ('IMAGE', 'VIDEO') ORDER BY " + "media_file.id" }; try { // Issues the search request and prints the results. int count = 0; foreach (GoogleAdsRow row in googleAdsService.Search(request)) { MediaFile mediaFile = row.MediaFile; Console.WriteLine($"Media file with ID {mediaFile.Id}, name " + $"'{mediaFile.Name}', and type '{mediaFile.Type}' was found."); count++; } if (count == 0) { // Displays a response if no media files are found. if (count == 0) { Console.WriteLine("No media files found."); } } } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }
/// <summary> /// Runs the code example. /// </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="campaignId">If specified, the search result is restricted only to this /// campaign ID.</param> public void Run(GoogleAdsClient client, long customerId, long?campaignId) { // Get the AdGroupService. GoogleAdsServiceClient googleAdsService = client.GetService( Services.V10.GoogleAdsService); // Create the search query. string searchQuery = "SELECT campaign.id, ad_group.id, ad_group.name FROM ad_group"; if (campaignId != null) { searchQuery += $" WHERE campaign.id = {campaignId}"; } try { // Retrieve the campaigns. PagedEnumerable <SearchGoogleAdsResponse, GoogleAdsRow> searchPagedResponse = googleAdsService.Search(customerId.ToString(), searchQuery); // Display the results. foreach (GoogleAdsRow googleAdsRow in searchPagedResponse) { AdGroup adGroup = googleAdsRow.AdGroup; if (adGroup != null) { Console.WriteLine("Ad group with ID {0} and name '{1}' was found in " + "campaign with ID: {2}.", adGroup.Id, adGroup.Name, googleAdsRow.Campaign.Id); } else { Console.WriteLine("No ad group found for row."); } } } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }
/// <summary> /// Returns the DSA settings for a campaign. Throws an error if the campaign does not /// exist or is not a DSA campaign. /// </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="campaignId">ID of the campaign for which DSA settings are fetched.</param> /// <returns>The DSA settings.</returns> private DynamicSearchAdsSetting GetDsaSetting(GoogleAdsClient client, long customerId, long campaignId) { // Get the GoogleAdsService. GoogleAdsServiceClient googleAdsService = client.GetService( Services.V3.GoogleAdsService); // Creates the query. // You must request all DSA fields in order to update the DSA settings in the // following step. string query = "SELECT " + "campaign.id, " + "campaign.name, " + "campaign.dynamic_search_ads_setting.domain_name, " + "campaign.dynamic_search_ads_setting.language_code, " + "campaign.dynamic_search_ads_setting.use_supplied_urls_only " + "FROM " + "campaign " + "WHERE " + "campaign.id = " + campaignId; GoogleAdsRow result = googleAdsService.Search( customerId.ToString(), query).FirstOrDefault(); if (result == null) { throw new Exception("No campaign found with ID: " + campaignId); } // Gets the DSA settings. DynamicSearchAdsSetting dynamicSearchAdsSetting = result.Campaign.DynamicSearchAdsSetting; // Throws an exception if the campaign is not a DSA campaign. if (dynamicSearchAdsSetting == null || string.IsNullOrEmpty( dynamicSearchAdsSetting.DomainName)) { throw new Exception($"Campaign with ID {campaignId} is not a DSA campaign."); } return(dynamicSearchAdsSetting); }
/// <summary> /// Runs the code example. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The Google Ads customer ID for which the call is made.</param> public void Run(GoogleAdsClient client, long customerId) { // Get the GoogleAdsService. GoogleAdsServiceClient googleAdsService = client.GetService( Services.V10.GoogleAdsService); // Construct a query to retrieve the customer. // Add a limit of 1 row to clarify that selecting from the customer resource // will always return only one row, which will be for the customer // ID specified in the request. string query = "SELECT customer.id, customer.descriptive_name, " + "customer.currency_code, customer.time_zone, customer.tracking_url_template, " + "customer.auto_tagging_enabled FROM customer LIMIT 1"; // Executes the query and gets the Customer object from the single row of the response. SearchGoogleAdsRequest request = new SearchGoogleAdsRequest() { CustomerId = customerId.ToString(), Query = query }; try { // Issue the search request. Customer customer = googleAdsService.Search(request).First().Customer; // Print account information. Console.WriteLine("Customer with ID {0}, descriptive name '{1}', currency " + "code '{2}', timezone '{3}', tracking URL template '{4}' and auto tagging " + "enabled '{5}' was retrieved.", customer.Id, customer.DescriptiveName, customer.CurrencyCode, customer.TimeZone, customer.TrackingUrlTemplate, customer.AutoTaggingEnabled); } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }