Error while getting the campaign performance report

44 views
Skip to first unread message

SML Analysis

unread,
Aug 19, 2019, 9:09:53 PM8/19/19
to AdWords API and Google Ads API Forum


Dear All

I am getting error while retrieving records of campaign performance reports. The error I am getting on the column Search Impression share information where the data contain < 10% or >90 %. The tool I am using MS visual studio language C# and I have the latest Nuget i.e. 24.8.0 installed for the project. screenshot of the error is attached. The code is as below.

  public void CampaignPerformanceReport(AdWordsUser user,string periodfrom, string periodto)
        {
            // Retreiving the raw values of enum-type fields instead of display values
            (user.Config as AdWordsAppConfig).UseRawEnumValues = true;
            (user.Config as AdWordsAppConfig).ClientCustomerId = "xxx-xxx-xxxx";

            // Create the query.
            String query = "select CampaignName,  Clicks, Impressions, Cost, Conversions, Month, " +
                            "AveragePosition,OfflineInteractionRate, SearchImpressionShare," +
                            "SearchRankLostImpressionShare,SearchBudgetLostImpressionShare,NumOfflineInteractions " +
                            "  FROM   CAMPAIGN_PERFORMANCE_REPORT WHERE Impressions>=1 DURING " +periodfrom+","+ periodto ;

            ReportUtilities reportUtilities = new ReportUtilities(user, "v201809", query,
                DownloadFormat.GZIPPED_XML.ToString());
           // reportUtilities.User.Config.
            try
            {
                using (ReportResponse response = reportUtilities.GetResponse())
                {
                    using (GZipStream gzipStream =
                      new GZipStream(response.Stream,
                        CompressionMode.Decompress))
                    {
                        // Create the report object using the stream.
                        using (var report = new AwReport<CampaignPerformanceReportReportRow>(
                            new AwXmlTextReader(gzipStream), "Example"))
                        {
                            //DataTable dt = (DataTable)report.Rows;
                            //return dt;
                            foreach (var item in report.Rows)
                            {
                                CampaignPerformanceClass cpc = new CampaignPerformanceClass();
                                cpc.AccountID = "xxx-3xx-xxx";
                                cpc.AveragePosition = (decimal) item.averagePosition;
                                cpc.CampaignName = item.campaignName;
                                cpc.Clicks = (decimal)item.clicks;
                                cpc.Conversions = (decimal)item.conversions;
                                cpc.Cost = (decimal)item.cost;
                                cpc.Impressions = (decimal)item.impressions;
                                cpc.Month = Convert.ToDateTime( item.month);
                                cpc.NumOfflineInteractions = (decimal)item.numOfflineImpressions;
                                cpc.OfflineInteractionRate = (decimal)item.offlineInteractionRate;
                                cpc.SearchImpressionShare = (decimal)item.searchImpressionShare;
                                cpc.SearchRankLostImpressionShare = (decimal)item.searchRankLostImpressionShare;
                                cpc.SearchBudgetLostImpressionShare = (decimal)item.searchBudgetLostImpressionShare;

                                CampaignPerformanceDataClass.Add(cpc );
                            }
                            CampaignGrid.DataSource = report.Rows;
                            CampaignGrid.DataBind(); 
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw new System.ApplicationException("Failed to download and parse report.", e);
            }
        }

Regards
Ali 
error.jpg

Google Ads API Forum Advisor Prod

unread,
Aug 19, 2019, 9:59:54 PM8/19/19
to adwor...@googlegroups.com
Hi,

Could you confirm if there are any implemented post processing in the reports after it has been downloaded? I asked because, based on the logs, the issue appears that it may not have originated from the AdWords servers. Could you try and generate the report using the client library example without your current code?

You can refer to and use this readily made example to isolate the issue if it is indeed coming from the AdWords API or if it is from the C# client library itself. Let me know if the issue persists.

Thanks and regards,
Peter
Google Ads API Team

ref:_00D1U1174p._5001UHE1nM:ref

SML Analysis

unread,
Aug 20, 2019, 3:12:57 AM8/20/19
to AdWords API and Google Ads API Forum
Hi,

Ok thank you I will give it a try and will let you know.

what I am actually trying to do here is to read one by one rows and save it in our DB for reporting purpose. Is there a way I can save the response from Google into a C# Datatable and update it using bulk query into DB.

Regards
Ali

Google Ads API Forum Advisor Prod

unread,
Aug 20, 2019, 3:20:54 AM8/20/19
to adwor...@googlegroups.com
Hi,

You may try and download the results of the report as objects as seen in this example. This way, it could be an easier approach than parsing the generated file itself. I hope this helps.

Best regards,
Reply all
Reply to author
Forward
0 new messages