我正在使用Angulartics和Angulartics谷歌分析1跟踪用户流量在一个角度的页面。跟踪事件运行良好。此外,跟踪页面查看是自动和工作的。,但是在Google仪表板中,我看不到url.的锚部分。
跟踪请求如下所示:
https://www.google-analytics.com/collect?
v=1&_v=j51&a=333486222&t=screenview&_s=7&
cd=%2Findex.html%23%2Fsign-in&
dl=http%3A%2F%2Flocalhost%2Findex.html&
ul=de&de=UTF-8&
dt=Treat&
sd=24-bit&sr=1918x941&
vp=1918x845&je=0&
fl=25.0%20r0&an=Treats&_u=SACAAMABO~&jid=&
gjid=&cid=1883662174.1492999789&
uid=Mark-user&tid=UA-9675XXXX-1&z=124537179注意cd=%2Findex.html%23%2Fsign-in是如何包含URI的#sign-in部分的,但是重要的dl=http%3A%2F%2Flocalhost%2Findex.html没有。
我的app.js看起来是这样的:
... }).config(function ($analyticsProvider) {
$analyticsProvider.firstPageview(true); /*Records pages that don't use $state or $route*/
$analyticsProvider.withAutoBase(true); /*Records full path*/
$analyticsProvider.virtualPageviews(true);
});
;如何使用Angulartics跟踪完整的URI,包括页面查看锚,而无需使用手动触发代码?
发布于 2017-05-16 12:15:08
我确实通过禁用内置页面查看和在stateChangeSuccess事件处理程序中进行跟踪来解决这个问题,如下所示:
angular.module('starter', ['ionic', ... ,'angulartics',
'angulartics.google.analytics',
'angulartics.google.analytics.cordova','angulartics.mixpanel'])
.run(function($rootScope, $state, $analytics, $location){
$rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams){
// we do not use Angulartics virtual pageviews, instead we track them "manually" here because of
// https://github.com/angulartics/angulartics/issues/550
// also we track pageviews as events with the pageview path as event name to use the low cost plan of https://mixpanel.com/pricing/
var currentPath = $location.path();
$analytics.pageTrack(currentPath);
$analytics.eventTrack(currentPath, {category: 'pageview', label: 'pageview'});
});
});重点是使用$analytics.pageTrack调用location.path。效果很好!我还在项目网站上报告了一个bug。
https://stackoverflow.com/questions/43590466
复制相似问题