【问题标题】:How to use custom dimension in Analytics reporting in php如何在 php 的分析报告中使用自定义维度
【发布时间】:2019-07-19 11:42:27
【问题描述】:

我正在设置一个从谷歌分析获取数据的报告脚本。我正在添加三个维度来获取数据,但其中一个维度是名为 test_dimension 的自定义维度。当我设置这个维度时,我得到了这个错误。

未知维度:test_dimension

我尝试了开发者 API,但无法获得预期的结果 https://developers.google.com/analytics/devguides/reporting/core/dimsmets#view=detail&group=custom_variables_or_columns&jump=ga_dimensionxx

$custom = new Google_Service_AnalyticsReporting_Dimension();
$custom->setName("test_dimension");

$campaign = new Google_Service_AnalyticsReporting_Dimension();
$campaign->setName("ga:campaign");

$sourceMedium = new Google_Service_AnalyticsReporting_Dimension();
$sourceMedium->setName("ga:sourceMedium");

$request->setDimensions(array($custom,$campaign,$sourceMedium));

$body = new Google_Service_AnalyticsReporting_GetReportsRequest();
$body->setReportRequests( array( $request) );
return $analytics->reports->batchGet( $body );

我希望输出具有应用的尺寸。如果我删除自定义维度,则代码有效。

【问题讨论】:

    标签: php google-analytics-api


    【解决方案1】:

    您需要使用自定义维度的索引(例如ga:dimension03)而不是其名称。该索引在 自定义定义 下的属性管理设置中可见。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-27
      相关资源
      最近更新 更多