如何将 Google Analytics 集成到 GWT 应用程序中?
How do I integrate Google Analytics into GWT applications?
我有两个问题...1。我从未使用过 google 分析,并且 2. 到目前为止,我从未使用、制作或接触过 GWT 项目。我正在尝试让 google 分析与 GWT 应用程序一起使用。我通读了这个:How to integrate Google Analytics into GWT using the asynchronous script 以及它链接到的问题,但运气不好。
There is a new version of Google Analytics out which uses a new
analytics.js script. It's the same process though, just add the script
in your html header:
<script>
(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','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-YOUR_ACCOUNT-X', 'auto');
ga('send', 'pageview'); </script>
就我而言,项目很大,我不确定我需要将 google analyics js 放入哪个 html 文件。我假设 html 文件在war 文件夹。
至于这个位:
call the new methods like so:
public static native void googleAnalyticsTrackPageView(String url)/*-{
$wnd.ga('send', 'pageview', url); }-*/;
我完全不确定我需要在哪里包含它。
哦,最后一个问题。这仍然是我在本地测试的方式吗?
ga('create', 'UA-XXXX-Y', {'cookieDomain': 'none'});
在您的 war 文件夹中应该有一个 index.html 或 index.jsp 文件用于 GWT JS 文件 (xxx-nocache.js)。您需要将脚本放在那里。
或者,您也可以使用 Arcbee 的 universal-analytics 库。
我有两个问题...1。我从未使用过 google 分析,并且 2. 到目前为止,我从未使用、制作或接触过 GWT 项目。我正在尝试让 google 分析与 GWT 应用程序一起使用。我通读了这个:How to integrate Google Analytics into GWT using the asynchronous script 以及它链接到的问题,但运气不好。
There is a new version of Google Analytics out which uses a new analytics.js script. It's the same process though, just add the script in your html header:
<script> (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','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-YOUR_ACCOUNT-X', 'auto'); ga('send', 'pageview'); </script>
就我而言,项目很大,我不确定我需要将 google analyics js 放入哪个 html 文件。我假设 html 文件在war 文件夹。
至于这个位:
call the new methods like so:
public static native void googleAnalyticsTrackPageView(String url)/*-{ $wnd.ga('send', 'pageview', url); }-*/;
我完全不确定我需要在哪里包含它。
哦,最后一个问题。这仍然是我在本地测试的方式吗?
ga('create', 'UA-XXXX-Y', {'cookieDomain': 'none'});
在您的 war 文件夹中应该有一个 index.html 或 index.jsp 文件用于 GWT JS 文件 (xxx-nocache.js)。您需要将脚本放在那里。
或者,您也可以使用 Arcbee 的 universal-analytics 库。