Posts under category google-ads-api

I want to update our code for the new Google Ads API but I cant find the API Center in Google Ads Dashboard with the main account.

When I open the url to API Center than came this message: Only administrative account users have access to the API Center. For more information, see the API login guide

Has anyone a idea or is there another way to get the Developer Token?

I have a application with a ads. And i have a 1 banner ads. Can i use same unit id for use more than 1 banner only ? Like if i want use 3 banner should i take 3 diffrent banner id or same is working well too ? I googled it but cant found any document or same question as i asked thats why i want to ask in here .If i can use then i will put two or three ads with same id. And is it effecting money to get ? I just need informations about it. Thanks for helps :)

secondBanner = BannerAd(       size: AdSize.banner,       adUnitId: "MyBannerId",       listener: BannerAdListener(onAdLoaded: (ad) {         setState(() {           secondBannerLoaded = true;         });         print("Banner AD LOADED!!!!!!!!!!!");       }, onAdFailedToLoad: (ad, error) {         print("Banner AD ERRRRRRRRRRRRRRRRRRRR!!!!!!!!!!!");         inspect(error);         ad.dispose();       }),       request: AdRequest(),     );     bannerAd = BannerAd(       size: AdSize.banner,       adUnitId: "MyBannerId",       listener: BannerAdListener(onAdLoaded: (ad) {         setState(() {           isLoaded = true;         });         print("Banner AD LOADED!!!!!!!!!!!");       }, onAdFailedToLoad: (ad, error) {         print("Banner AD ERRRRRRRRRRRRRRRRRRRR!!!!!!!!!!!");         inspect(error);         ad.dispose();       }),       request: AdRequest(),     );     bannerAd!.load();     secondBanner!.load(); 

I need help with getting metrics for sitelink extensions. I have tried this query but no results are returned. I can see 6 sitelink extensions in the UI.

SELECT campaign.name, feed_item.attribute_values, metrics.clicks, metrics.impressions, metrics.ctr , segments.interaction_on_this_extension, segments.placeholder_type FROM feed_item WHERE segments.date BETWEEN '2022-04-10' AND '2022-05-10' ORDER BY metrics.clicks DESC LIMIT 10

The code below is what I'm currently using to generate a JSON representation of the captured data. My question is, is the use of the Google.Protobuf.Reflection.MessageDescriptor and the use of Reflection. The code appears to work. However, is there a better way to do this?

The code is called by a ClearScript-enabled JavaScript instance, thus the strings rather than longs in the parameters.

public string GenerateHistoricalMetrics(GoogleAdsClient client, string customerIdString, string locationIdsList,string languageIdString, string keywordTextsList, string pageUrl, bool debug = true) {     if (debug) Debugger.Launch();     long[] locationIds = (from id in locationIdsList.Split(',') select long.Parse(id)).ToArray();     string[] keywordTexts = keywordTextsList.Split(',');     long customerId = long.Parse(customerIdString);     long languageId = long.Parse(languageIdString);     KeywordPlanIdeaServiceClient keywordPlanIdeaService =         client.GetService(Services.V10.KeywordPlanIdeaService);     // Make sure that keywords and/or page URL were specified. The request must have     // exactly one of urlSeed, keywordSeed, or keywordAndUrlSeed set.     if (keywordTexts.Length == 0 && string.IsNullOrEmpty(pageUrl))     {         return JsonConvert.SerializeObject(new JSON() { Error = "At least one of keywords or page URL is required, but neither was specified." });     }     // Specify the optional arguments of the request as a keywordSeed, UrlSeed,     // or KeywordAndUrlSeed.     GenerateKeywordIdeasRequest request = new GenerateKeywordIdeasRequest()     {         CustomerId = customerId.ToString(),     };     if (keywordTexts.Length == 0)     {         // Only page URL was specified, so use a UrlSeed.         request.UrlSeed = new UrlSeed()         {             Url = pageUrl         };     }     else if (string.IsNullOrEmpty(pageUrl))     {         // Only keywords were specified, so use a KeywordSeed.         request.KeywordSeed = new KeywordSeed();         request.KeywordSeed.Keywords.AddRange(keywordTexts);     }     else     {         // Both page URL and keywords were specified, so use a KeywordAndUrlSeed.         request.KeywordAndUrlSeed = new KeywordAndUrlSeed         {             Url = pageUrl         };         request.KeywordAndUrlSeed.Keywords.AddRange(keywordTexts);     }     // Create a list of geo target constants based on the resource name of specified     // location IDs.     foreach (long locationId in locationIds)     {         request.GeoTargetConstants.Add(ResourceNames.GeoTargetConstant(locationId));     }     request.Language = ResourceNames.LanguageConstant(languageId);     // Set the network. To restrict to only Google Search, change the parameter below to     // KeywordPlanNetwork.GoogleSearch.     request.KeywordPlanNetwork = KeywordPlanNetwork.GoogleSearch; //.GoogleSearchAndPartners;     var list = new List<Dictionary<string, object>>();     try     {         // Generate keyword ideas based on the specified parameters.         var response =             keywordPlanIdeaService.GenerateKeywordIdeas(request);         // Iterate over the results and print its detail.         foreach (GenerateKeywordIdeaResult result in response)         {             KeywordPlanHistoricalMetrics metrics = result.KeywordIdeaMetrics;             Google.Protobuf.Reflection.MessageDescriptor descriptor = GenerateKeywordIdeaResult.Descriptor;             foreach (var field in descriptor.Fields.InDeclarationOrder())             {                 object value = field.Accessor.GetValue(result);                 if (value != null)                 {                     var props = value.GetType().GetProperties(BindingFlags.Public | BindingFlags.GetProperty | BindingFlags.GetField | BindingFlags.Instance);                     var dict = new Dictionary<string, object>();                     foreach (string key in from prop in props                                         let key = Title(field.JsonName) + "." + prop.Name                                         where key.StartsWith("Keyword")                                         select key                     )                     {                         dict.Add(key, value);                     }                     if (dict.Count() > 0)                         list.Add(dict);                 }             }         }     }     catch (GoogleAdsException e)     {         return JsonConvert.SerializeObject(new JSON() { Error = $"Failure: Message: {e.Message}, Failure: {e.Failure}, Request ID: {e.RequestId}" });     }     return JsonConvert.SerializeObject(new JSON() { Cargo = list, Crew = resultList }); }