use*_*011 6 google-analytics cordova angular
我正在使用Angulartics和Angulartics Google Analytics [1]来跟踪角度页面中的用户流.跟踪事件运作良好.跟踪网页浏览也是自动且有效的.但是,在Google Analytics信息中心中,我无法看到网址的锚点部分.
跟踪请求如下所示:
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
Run Code Online (Sandbox Code Playgroud)
请注意如何cd=%2Findex.html%23%2Fsign-in包含#sign-inURI的一部分,但重要的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);
});
;
Run Code Online (Sandbox Code Playgroud)
如何跟踪完整的URI,包括使用Angulartics进行综合浏览的锚点,而无需使用手动触发器代码?
[1] https://github.com/angulartics/angulartics-google-analytics
[2] https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#location
我确实通过禁用内置页面视图并在 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'});
});
});
Run Code Online (Sandbox Code Playgroud)
重点是用 来$analytics.pageTrack调用location.path。效果很好!我还在项目网站上报告了一个错误。
| 归档时间: |
|
| 查看次数: |
383 次 |
| 最近记录: |