GWT and Tickling your Google Analytics Urchin
To see how the new Google Analytics Urchin is integrated with GWT ToCollege.net see the decorator
tocollege.net/src/main/webapp/decorators/default.dec
At the bottom it contains the Analytics page tracker:
The analytics code is in this one file. ToCollege.net uses
SiteMesh to decorate all of the pages in the site with this decorator, so if you're using SiteMesh this is still the HTML you'll need.
Because GWT will allow you to navigation within a page without reloading the page, you may end up with fewer page views than you'd like and no way to track what users are doing on your site. The way around this is to poke the urchin to let it know that it should record another page view.
See the JSUtils.java file, which has a 'tickleUrchin'
method. This is a JSNI hook so that you can trigger a Google Analytics
page view from within GWT.
tocollege.net/src/main/webapp/decorators/default.dec
At the bottom it contains the Analytics page tracker:
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-YOUR_TRACKER");
pageTracker._initData();
pageTracker._trackPageview();
</script>
The analytics code is in this one file. ToCollege.net uses
SiteMesh to decorate all of the pages in the site with this decorator, so if you're using SiteMesh this is still the HTML you'll need.
Because GWT will allow you to navigation within a page without reloading the page, you may end up with fewer page views than you'd like and no way to track what users are doing on your site. The way around this is to poke the urchin to let it know that it should record another page view.
See the JSUtils.java file, which has a 'tickleUrchin'
method. This is a JSNI hook so that you can trigger a Google Analytics
page view from within GWT.
For more info on the GWT 1.5.3 code behind ToCollege.net check out the Google Group