Hi,
I'm downloading the keyword performance report for further processing. When downloading the report using "Conversion Name" segment, the downloaded report has different values compared to the same report downloaded via the browser. We have 2 conversions we are tracking : "Needs Posted" and "Needs Paid". The "Needs Posted" values are fine, however the "Needs Paid" segment is reporting very few results : 870 vs 5 in the report downloaded via the API.
The code is below:
public void DownloadKeywordReport_ConversionName(string reportType, string dateRange, string filters, string MCCAccount, DateTime repStartDate, DateTime repEndDate)
{
ReportDefinition definition = new ReportDefinition();
Selector selector = new Selector();
definition.reportName = reportType;
if (reportType == "KEYWORDS_PERFORMANCE_REPORT")
definition.reportType = ReportDefinitionReportType.KEYWORDS_PERFORMANCE_REPORT;
else if (reportType == "CAMPAIGN_PERFORMANCE_REPORT")
definition.reportType = ReportDefinitionReportType.CAMPAIGN_PERFORMANCE_REPORT;
else if (reportType == "SEARCH_TERM_PERFORMANCE_REPORT")
definition.reportType = ReportDefinitionReportType.SEARCH_QUERY_PERFORMANCE_REPORT;
else Console.WriteLine("{0} - is an undefined report type", reportType);
definition.downloadFormat = DownloadFormat.CSV;
if (dateRange == "LAST_7_DAYS")
definition.dateRangeType = ReportDefinitionDateRangeType.LAST_7_DAYS;
else if (dateRange == "YESTERDAY")
definition.dateRangeType = ReportDefinitionDateRangeType.YESTERDAY;
else if (dateRange == "ONE_DAY")
{
definition.dateRangeType = ReportDefinitionDateRangeType.CUSTOM_DATE;
DateRange repdateRange = new DateRange { min = reportDate.ToString(@"yyyyMMdd"), max = reportDate.ToString(@"yyyyMMdd") };
selector.dateRange = repdateRange;
}
else if (dateRange == "CUSTOM_RANGE")
{
definition.dateRangeType = ReportDefinitionDateRangeType.CUSTOM_DATE;
DateRange repdateRange = new DateRange { min = repStartDate.ToString(@"yyyyMMdd"), max = repEndDate.ToString(@"yyyyMMdd") };
selector.dateRange = repdateRange;
}
selector.fields = new string[] {
"ConversionTypeName",
"KeywordText",
"Conversions",
"CampaignName",
"CampaignId",
};
definition.selector = selector;
definition.includeZeroImpressions = false;
try
{
AdWordsUser user = new AdWordsUser();
AdWordsAppConfig config = (AdWordsAppConfig)user.Config;
config.ClientCustomerId = MCCAccount;
config.DeveloperToken = this.MCCAccount.developerToken;
config.OAuth2ClientId = this.MCCAccount.OAuth2ClientId;
config.OAuth2ClientSecret = this.MCCAccount.OAuth2ClientSecret;
config.OAuth2RefreshToken = this.MCCAccount.OAuth2RefreshToken;
ReportUtilities utilities = new ReportUtilities(user);
ClientReport report = utilities.GetClientReport(definition);
string deflatedReportText = Encoding.UTF8.GetString(report.Contents);
List<string> lines = deflatedReportText.Split('\n').ToList();
JawabkomCommon.Utilities.WriteFileWithAutoIncrement("KeywordSegmentDownload.csv", lines);