【问题标题】:Can I call the Multi Channel Funnel mcf from within Apps script?我可以从 Apps 脚本中调用 Multi Channel Funnel mcf 吗?
【发布时间】:2015-06-08 20:07:33
【问题描述】:

我正在学习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');
  }
}

【问题讨论】:

  • 错误是什么?我能看到的唯一语法错误是采样级别应该是采样级别,但是您已将其注释掉。

标签: google-apps-script google-analytics


【解决方案1】:

我想你用 mcf 代替了 Mcf:

var results = Analytics.Data.Mcf.get

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多