gpt4 book ai didi

angularjs - 如何使用 Google Analytics 跟踪 ServiceNow 服务门户 (AngularJS) 页面 View ?

转载 作者:行者123 更新时间:2023-12-01 21:19:36 24 4
gpt4 key购买 nike

我正在寻求帮助,让 Google Analytics 与 ServiceNow 的服务门户(基于云的服务管理平台)配合使用。该平台使用 AngularJS。我在每个页面的标题中都有以下代码:

$rootScope.$on('$locationChangeSuccess', function(event, toState, toParams){        
ga('send', {
hitType: 'pageview',
title: $window.document.title,
location: $location.absUrl()
});
})

当我在浏览器的调试器中设置断点时,我可以看到断点被命中并且代码正在被调用。 enter image description here

但是,当调用上述代码时,我在 Google Analytics 实时仪表板中没有看到任何记录: enter image description here

我尝试替换 $locationChangeSuccess$locationChangeStart$stateChangeSuccess

我尝试过$location.absUrl()$location.path()

我似乎无法让上述工作发挥作用。我宁愿必须使用第三方脚本,如 angular-google-analyticsautotrack如果可能的话。

最佳答案

我终于记得查看浏览器的控制台日志,并看到导致我的问题的错误:错误:$window 未定义

我需要在客户端脚本函数声明中添加 $window 变量:

function ($rootScope, $scope, snRecordWatcher, spUtil, $location, $uibModal, cabrillo, $timeout, $window) {

关于angularjs - 如何使用 Google Analytics 跟踪 ServiceNow 服务门户 (AngularJS) 页面 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47357075/

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