angular - 如何通过 Angular 5 在单个页面中获取多个标签的谷歌分析
问题描述
我可以获得路线的谷歌分析,如果我们导航不同的路线,它正在工作,但在一个页面内我有多个标签。我想要基于标签的谷歌分析导航。请参考下面的上传图片以供参考。先感谢您
ga('create', 'UA-XXXXXX-Y', {'userId': customUserId}); // 如果“用户 ID”功能可用 ga('require', 'displayfeatures'); ga('set', 'dimension1', customUserId); //customUserId
在页面级别设置维度 ga('send', 'pageview'); 在此处输入图像描述
解决方案
您必须为此捕获自定义事件
//Function in service.ts file
googleEventTrack(eventCategory,eventLabel,eventAction,eventValue) {
(<any>window).ga('send', 'event', {
eventCategory: eventCategory,
eventLabel: eventLabel,
eventAction: eventAction,
eventValue: eventValue
});
}
//capture event on button click in component.ts
btnClick(){
this.CommonService.googleEventTrack('eventCategory', 'eventLabel',
'eventAction', 'eventValue');
}
推荐阅读
- linux - 在远程机器上执行 curl
- javascript - 为什么这个程序打印 3 而不是 2?
- java - Android firebase 获取 ch 数据库
- material-ui - 从 Material UI v0.x 迁移到 v1.y 的步骤
- javascript - 如何在CKEditor插件中更改边框
- asp.net - 多项目asp.net解决方案中的资源问题
- php - 执行时间查询时遇到一些问题
- git - Jenkins Git Refspec 未正确替换分支说明符
- .net - 如何强制等待在控制台应用程序中的同一调用者线程中继续
- r - R igraph:Barabasi-Model start.graph 顶点过多