gpt4 book ai didi

cordova - Angular 学 : Google Analytics track full URI including anchor

转载 作者:太空狗 更新时间:2023-10-29 17:28:55 25 4
gpt4 key购买 nike

我正在使用 Angulartics 和 Angulartics Google Analytics [1] 来跟踪 Angular 页面中的用户流。跟踪事件效果很好。跟踪综合浏览量也是自动的并且有效。 但是在 Google Analytics 仪表板中我看不到 url 的 anchor 部分。

跟踪请求如下所示:

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 跟踪包括网页浏览 anchor 在内的完整 URI?

[1] https://github.com/angulartics/angulartics-google-analytics

[2] https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#location

最佳答案

我确实通过在 stateChangeSuccess 事件处理程序中禁用内置页面 View 和跟踪来解决这个问题,如下所示:

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'});
});
});

重点是用location.path调用$analytics.pageTrack。效果很好!我还在项目网站上报告了一个错误。

关于cordova - Angular 学 : Google Analytics track full URI including anchor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43590466/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com