如何使用Google.Apis.AdSense从Google AdSense获取点击率

时间:2016-05-09 20:14:48

标签: c# .net google-api adsense

我正在使用Google.Apis.AdSense从C#windows窗体中获取AdSense数据。 我可以获得adsense信息和度量报告,使用Metric我可以优化一些值,例如

["PAGE_VIEWS",
"INDIVIDUAL_AD_IMPRESSIONS",
"CLICKS","AD_REQUESTS_CTR",
"INDIVIDUAL_AD_IMPRESSIONS_CTR",
"COST_PER_CLICK","AD_REQUESTS_RPM",
"INDIVIDUAL_AD_IMPRESSIONS_RPM",
"AD_REQUESTS_COVERAGE","EARNINGS"]

此处为此流程的代码:

public AdsenseReportsGenerateResponse GenerateReport(Account adSenseAccount, DateTime startDate, DateTime endDate)
{
    var reportRequest = service.Accounts.Reports.Generate(
        adSenseAccount.Id, startDate.ToString(DateFormat), endDate.ToString(DateFormat));

    reportRequest.Metric = new List<string>
    {
     "PAGE_VIEWS","INDIVIDUAL_AD_IMPRESSIONS", "CLICKS","AD_REQUESTS_CTR","INDIVIDUAL_AD_IMPRESSIONS_CTR",
     "COST_PER_CLICK","AD_REQUESTS_RPM","INDIVIDUAL_AD_IMPRESSIONS_RPM", "AD_REQUESTS_COVERAGE","EARNINGS"
    };
    reportRequest.Dimension = new List<string> { "DATE" };
    reportRequest.Sort = new List<string> { "+DATE" };

    // Run report.
    var reportResponse = reportRequest.Execute();
    ReportUtils.FillGapsDates(reportResponse, startDate, endDate);

    if (!reportResponse.Rows.IsNullOrEmpty())
    {
        ReportUtils.DisplayHeaders(reportResponse.Headers);
        Console.WriteLine("Showing data from {0} to {1}", reportResponse.StartDate, reportResponse.EndDate);
        return reportResponse;
    }
    else
    {
        return null;
    }
}

第一期: 虽然数据不相同,但它们是相似的。为什么呢?

第二期(重要): 我如何或在哪里获得点击率? 目前,我们计算了以下等式:

INDIVIDUAL_AD_IMPRESSIONS_CTR * 2 * 100

这是对的吗?

0 个答案:

没有答案