我可以在Apps脚本中调用多渠道漏斗mcf吗?

时间:2015-06-08 20:07:34

标签: google-apps-script google-analytics

我正在完成this教程,让事情有效。

然后我尝试编辑它以从Google Analytics多渠道渠道获取数据:

这可以使用核心报告API(Analytics.Data.Ga.get(...)     function getReportDataForProfile(profile){//我之前已经定义了我的个人资料ID

  var startDate = getLastNdays(750);   // 2 weeks (a fortnight) ago.
  var endDate = getLastNdays(0);      // Today.

  var optArgs = {
    'dimensions': 'ga:medium', // Comma separated list of dimensions.
    'start-index': '1',
    'max-results': '10000'                     // Display the first 10000 results.
    //'sampling-level': 'higher-precision',
  };

  // Make a request to the API.
  var results = Analytics.Data.Ga.get( // mcf for multi channel api, Ga for core
      profile,                    // Table id (format ga:xxxxxx).
      startDate,                  // Start-date (format yyyy-MM-dd).
      endDate,                    // End-date (format yyyy-MM-dd).
      'ga:sessions', // Comma seperated list of metrics.
      optArgs);

  if (results.getRows()) {
    return results;

  } else {
    throw new Error('No views (profiles) found');
  }
}

该块稍微从教程编辑,但按预期工作 - 我得到数据。我试图修改它以从mcf获取数据:

这不起作用。为什么不呢?

function getReportDataForProfile(profile) {

  var startDate = getLastNdays(750);   // 2 weeks (a fortnight) ago.
  var endDate = getLastNdays(0);      // Today.

  var optArgs = {
    'dimensions': 'mcf:medium', // Comma separated list of dimensions.
    'start-index': '1',
    'max-results': '10000'                     // Display the first 10000 results.
    //'sampling-level': 'higher-precision',
  };

  // Make a request to the API.
  var results = Analytics.Data.mcf.get( // mcf for multi channel api, Ga for core
      profile,                    // Table id (format ga:xxxxxx).
      startDate,                  // Start-date (format yyyy-MM-dd).
      endDate,                    // End-date (format yyyy-MM-dd).
      'mcf:firstInteractionConversions', // Comma seperated list of metrics.
      optArgs);

  if (results.getRows()) {
    return results;

  } else {
    throw new Error('No views (profiles) found');
  }
}

1 个答案:

答案 0 :(得分:1)

我认为你用mcf而不是Mcf:

var results = Analytics.Data.Mcf.get

希望这有帮助。

相关问题