1
我尝试使用多页面模板开发jQuery Mobile应用程序。我想将Google Analytics添加到应用程序中。如何将Google Analytics与jQuery Mobile应用程序集成?
我参考这个文件,Using Google Analytics with jQuery Mobile。这似乎不适用于我的应用程序。
在我的应用程序的代码如下:
<script type="text/javascript">
var _gaq = _gaq || [];
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
$('[data-role=page]').on('pageshow', function (event, ui) {
try {
_gaq.push(['_setAccount', 'UA-30119852-1']);
hash = location.hash;
if (hash) {
_gaq.push(['_trackPageview', hash.substr(1)]);
} else {
_gaq.push(['_trackPageview']);
}
} catch(err) {
}
});
</script>
如何集成谷歌分析与jQuery Mobile应用程序?
谢谢。我今晚会尝试。 –
我知道这是旧的,但也许有人可能知道这个:event.target.id和hash.substr(1)之间的区别是什么,实际上并不一样? – rgdesign