Google analytics 为什么google universal analytics在我的webapp中不起作用?
我在我的webapp中使用GA,没有插件。我只是添加了analytics.js,并对其进行了一些修改,我认为这是它在webapp中工作所必需的(没有cookies、file://url等)。我遵循这里描述的技术-它似乎与分析文档一致 我也有一个应用程序的网络模拟器,我不做这些更改。在web emulator中,我可以看到请求在我调用它们的地方发出。在应用程序中,不会发生任何事情-没有错误,没有请求Google analytics 为什么google universal analytics在我的webapp中不起作用?,google-analytics,phonegap-build,Google Analytics,Phonegap Build,我在我的webapp中使用GA,没有插件。我只是添加了analytics.js,并对其进行了一些修改,我认为这是它在webapp中工作所必需的(没有cookies、file://url等)。我遵循这里描述的技术-它似乎与分析文档一致 我也有一个应用程序的网络模拟器,我不做这些更改。在web emulator中,我可以看到请求在我调用它们的地方发出。在应用程序中,不会发生任何事情-没有错误,没有请求 // google analytics (function(i,s,o,g,r,a
// google analytics
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','http://www.google-analytics.com/analytics.js','ga');
ga('create', this.settings.gatrackerid, 'auto');
if (!this.settings.emulate) {
// the app version
ga('set', {
'appName' : this.settings.appname,
'appId' : this.settings.appid,
'appVersion' : this.settings.version,
'checkProtocolTask' : null, // allow file://urls
'storage' : 'none', // no cookies available
'clientId' : device.uuid // well use phonegaps uuid
});
} else {
// the web version
ga('set', {
'appName' : this.settings.appname,
'appId' : 'emulate '+this.settings.appid,
'appVersion' : this.settings.version
});
}
ga('send', 'screenview',{
'screenName' : 'foo' // works on web, not in app
});
有人知道出了什么问题以及如何调试吗?我读错了blastam帖子。存储和客户端id应该替换create语句的第三个参数cookie info。创建跟踪器的代码是
ga('create', trackerid, cookieinfo)
在我的代码中,cookieinfo设置为“自动”。在网络上工作,而不是在应用程序中。正确的代码是
if (!this.settings.emulate) {
ga('create', this.settings.gatrackerid, {
'storage' : 'none',
'clientId' : device.uuid
});
ga('set', {
'appName' : this.settings.appname,
'appId' : this.settings.appid,
'appVersion' : this.settings.version,
'checkProtocolTask' : null
});
} else {
ga('create', this.settings.gatrackerid, 'auto');
ga('set', {
'appName' : this.settings.appname,
'appId' : 'emulate '+this.settings.appid,
'appVersion' : this.settings.version
});
}
这非常好,不需要插件。为什么不使用插件?我将其用于4种不同的PhoneGap构建应用程序。它很容易使用,工作也很好。无论我在哪里读到这个插件,他们都会说
你会得到一堆你不需要的东西,但这并不重要。
好吧,我不想,谢谢。。。这应该可以正常工作。此外,插件在emulator上不起作用,emulator是一个网页。