Google Analytics Reporting API v4是否有内置函数,可以在过滤器定义的所有页面中给出总页面浏览量?例如,当我拥有以下内容时:
我得到了这个结果:
非常感谢您的反馈。由于URL有几个变体,因此我只使用“BEGINS_WITH”。最好能够精确匹配并确保包括所有变体。
干杯 瑞安
$pageviews = new Google_Service_AnalyticsReporting_Metric();
$pageviews->setExpression("ga:pageviews");
$pageviews->setAlias("pageviews");
//Create the source dimension.
$source = new Google_Service_AnalyticsReporting_Dimension();
$source->setName("ga:pagePath");
$dimensionFilter = new Google_Service_AnalyticsReporting_DimensionFilter();
$dimensionFilter->setDimensionName("ga:pagePath");
$dimensionFilter->setOperator("BEGINS_WITH");
$dimensionFilter->setExpressions("/article/deleted-x-men-apocalypse-scene-awesome-tribute-80s");
$dimensionFilterClause = new Google_Service_AnalyticsReporting_DimensionFilterClause();
$dimensionFilterClause->setFilters(array($dimensionFilter));
// Create the ReportRequest object.
$request = new Google_Service_AnalyticsReporting_ReportRequest();
$request->setViewId($VIEW_ID);
$request->setDateRanges($dateRange);
$request->setDimensions(array($source));
$request->setDimensionFilterClauses(array($dimensionFilterClause));
$request->setMetrics(array($pageviews));
$body = new Google_Service_AnalyticsReporting_GetReportsRequest();
$body->setReportRequests( array( $request) );
return $analytics->reports->batchGet( $body );
我得到了这个结果:
ga:pagePath:
/article/deleted-x-men-apocalypse-scene-awesome-tribute-80s
pageviews: 6
ga:pagePath:
/article/deleted-x-men-apocalypse-scene-awesome-tribute-80s/
pageviews: 4458
ga:pagePath:
/article/deleted-x-men-apocalypse-scene-awesome-tribute-80s/?b_comment_id=fbc_1181872881884957_1181963985209180_1181963985209180
pageviews: 3
ga:pagePath:
/article/deleted-x-men-apocalypse-scene-awesome-tribute-80s/+ sadsHost
+ ":/api.avidadserver.com/api/Asms/Preview/?id=579c5f501ee0530bcc900738&pid=57c388e11ee0530a90c94fd9&w=300&h=250&rnd=[CACHE-BUSTING-ID-HERE]
width=
pageviews: 1
它会捕获包含URL查询的所有变体。我希望能够得到整个集合的总页面浏览量,这样我就不必自己添加了。还是有一种方法可以告诉API忽略? URL查询,并将它们全部包含为主要URL吗?非常感谢您的反馈。由于URL有几个变体,因此我只使用“BEGINS_WITH”。最好能够精确匹配并确保包括所有变体。
干杯 瑞安