Hello Thanet. I really appreciate your fast answer. I'm also working with the reporting feature approach, and I get an error saying "bad request". Maybe I'm missing something obvious in the definition. I was thinking to open another topic for it, but now that you mention it, I should take advantage right now :)
Ok let's go by parts. First, I need to find a way anyway to retrieve those clicks using these selectors <https://developers.google.com/adwords/api/docs/appendix/selectorfields#v201409-AdGroupService>, because our company want to see both approaches working, so please, if you can help me with that, I will really appreciate it. Now... about the reporting feature, this is what I am trying to do, following a combination of these instructions <https://developers.google.com/adwords/api/docs/guides/reporting> and this example <https://gist.github.com/ElvisLives/1287940>: string URL = "https://adwords.google.com/api/adwords/reportdownload/v201409"; string authToken = "xxxxxxx"; string clientId = "xxxxxx"; string fileName = "prueba"; string developerToken = "xxxxxx"; var request = WebRequest.Create(URL) as HttpWebRequest; request.ContentType = "application/x-www-form-urlencoded"; request.Method = "POST"; request.Headers.Add("Authorization", "Bearer " + authToken ); request.Headers.Add("developerToken", developerToken); request.Headers.Add("clientCustomerId", clientId); string xml = @"<reportDefinition> <selector> <fields>CampaignId</fields> <fields>Id</fields> <fields>Impressions</fields> <fields>Clicks</fields> <fields>Cost</fields> <predicates> <field>Status</field> <operator>IN</operator> <values>ENABLED</values> <values>PAUSED</values> </predicates> </selector> <reportName>Custom Adgroup Performance Report</reportName> <reportType>ADGROUP_PERFORMANCE_REPORT</reportType> <dateRangeType>LAST_7_DAYS</dateRangeType> <downloadFormat>CSV</downloadFormat> </reportDefinition>"; using (var sw = new StreamWriter(request.GetRequestStream())) { sw.Write("__rdxml=" + HttpUtility.UrlEncode(xml)); } using (var httpWebResponse = request.GetResponse() as HttpWebResponse) { if (httpWebResponse.StatusCode == HttpStatusCode.OK) { using (Stream stream = httpWebResponse.GetResponseStream()) { using (FileStream fileStream = File.Create(string.Format("{0}.csv", fileName))) { stream.CopyTo(fileStream); } } } } I replaced the AuthToken, clientId and the Developer Token just for security. When I run this code, I get an exception saying "Bad Request"... Example: <https://lh3.googleusercontent.com/-6W0slKg19PQ/VRQe9N_jXsI/AAAAAAAAAB8/vVmLk6ZRYJM/s1600/Reports%2BException.PNG> If I'm missing something obvious, just bare with me, because this is my first HTTP request, and first time working with Google Api also. Can you point me into the right direction? Why I receive the exception of bad request??? Also, there is a way to retrieve those clicks using these <https://developers.google.com/adwords/api/docs/appendix/selectorfields#v201409-AdGroupService> ? I will be kinda staring at my monitor waiting for your answer hehe. Thank you sir. On Thursday, March 26, 2015 at 10:13:58 AM UTC-4, Thanet Knack Praneenararat (AdWords API Team) wrote: > > Hi Samuel, > > Based on what you've described, it seems you may want to use reporting > <https://developers.google.com/adwords/api/docs/guides/reporting> feature > of the API. > > To get number of clicks and impressions for each campaign, you can use > Campaign > Performance Report > <https://developers.google.com/adwords/api/docs/appendix/reports/campaign-performance-report> > > to obtain those relevant fields. > > Please refer to this C# code example > <https://github.com/googleads/googleads-dotnet-lib/blob/master/examples/AdWords/CSharp/v201502/Reporting/DownloadCriteriaReport.cs> > for > more information. > In the code, Criteria Performance Report > <https://developers.google.com/adwords/api/docs/appendix/reports/criteria-performance-report> > > is specified but you can adapt to use Campaign Performance Report quite > easily. > > Best, > Thanet, AdWords API Team > > On Thursday, March 26, 2015 at 7:18:27 AM UTC+9, Samuel Otero wrote: >> >> Hi everyone. If someone can help me, I will really appreciate it. >> >> I am trying to get some basic information from a Campaign under my test >> MCC account. I am using Selector Fields >> <https://developers.google.com/adwords/api/docs/appendix/selectorfields#v201409-AdGroupService> >> to >> do so. >> >> I can get the Campaign Id, the Campaign Name, and some other info... but >> I just cannot find a way to retrieve the number of click at the Campaign >> Level, nor the Ad Groups level. >> >> Basically, I'm just trying to get all the information from this table: >> >> >> <https://lh3.googleusercontent.com/-uaEeGeSnd3M/VRMyx1hqHZI/AAAAAAAAAAM/e1HzQDls9os/s1600/Capture%2BForum.PNG> >> I can get my Campaign Name also... I just don't find any selector which I >> could retrieve those clicks. >> >> Here is an example of what I'm doing in C#: >> >> AdWordsUser user = new AdWordsUser(); >> >> CampaignService campaignService = >> (CampaignService)user.GetService(AdWordsService.v201409.CampaignService); >> DataService dataService = >> (DataService)user.GetService(AdWordsService.v201409.DataService); >> AdGroupService adGroupService = >> (AdGroupService)user.GetService(AdWordsService.v201409.AdGroupService); >> >> Selector CampaignServiceSelector = new Selector(); >> CampaignServiceSelector.fields = new string[] { "Name", "Id", >> "Status" }; >> >> >> Selector DataServiceSelector = new Selector(); >> DataServiceSelector.fields = new string[] {"LocalClicks", >> "LocalImpressions"}; >> >> Selector adGroupServiceSelector = new Selector(); >> adGroupServiceSelector.fields = new string[] { "Status", >> "Name" }; >> >> >> var campaignInfo = >> campaignService.get(CampaignServiceSelector); >> var dataServiceInfo = >> dataService.getCriterionBidLandscape(DataServiceSelector); >> var adGroupServiceInfo = >> adGroupService.get(adGroupServiceSelector); >> >> I'm just "playing" with the selectors, and I have a pretty good idea of >> how I will create the report that I want. I just don't find a selector to >> retrieve those clicks that I marked yellow at that picture. I tried to use >> DataService object, which have a method called "getAdGroupBidLandscape" >> that seems to have a selector that could work (LocalClicks) but when I use >> it, the code returns 0 entries. >> >> I'm lost! What selector I should use to retrieve those clicks? >> >> Please help! Thank you :) >> > -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog and Google+: https://googleadsdeveloper.blogspot.com/ https://plus.google.com/+GoogleAdsDevelopers/posts =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups "AdWords API Forum" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en --- You received this message because you are subscribed to the Google Groups "AdWords API Forum" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. Visit this group at http://groups.google.com/group/adwords-api. To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/11510c30-ac23-4e97-a4ed-9d3d1a72d1d3%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
