gpt4 book ai didi

ionic-framework - 在 Ionic 3 项目中使用 Google Analytics 跟踪所有屏幕

转载 作者:行者123 更新时间:2023-12-02 02:56:43 24 4
gpt4 key购买 nike

我正在完成 Ionic 3 构建,并想将 Google Analytics 添加到其中。我成功添加了它,并且可以在 GA(实时)中看到该应用程序正在被使用,但是我想跟踪所有页面/屏幕浏览量。有谁知道这样做的方法吗?

我正在使用以下插件:https://github.com/danwilson/google-analytics-plugin

这是我用来初始化 GA 的代码

 initGoogleAnalytics() {
var trackingId = 'UA-114720506-2';
if (/(android)/i.test(navigator.userAgent)) { // for android
trackingId = 'UA-114720506-2';
} else if (/(ipod|iphone|ipad)/i.test(navigator.userAgent)) { // for ios
trackingId = 'UA-114720506-2';
}
//platform is injected in the Constructor
this.platform.ready().then(() => {
this.ga.debugMode();
this.ga.startTrackerWithId(trackingId).then(()=> {
console.log("GoogleAnalytics Initialized with ****** : " + trackingId);
this.ga.trackView('schedule');
this.ga.trackView('speakerList');
this.ga.trackView('map');
this.ga.trackView('social');
this.ga.trackView('exhibitors');
this.ga.enableUncaughtExceptionReporting(true)
.then((_success) => {
console.log("GoogleAnalytics enableUncaughtExceptionReporting Enabled.");
}).catch((_error) => {
console.log("GoogleAnalytics Error enableUncaughtExceptionReporting : " + _error)
});
});
});
}

最佳答案

基本上添加 GA 模块并在我想跟踪的每个页面上使用 ionViewDidEnter 进行初始化就达到了目的。

关于ionic-framework - 在 Ionic 3 项目中使用 Google Analytics 跟踪所有屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48974371/

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