Reputation: 354
I have two problems...1. I have never used google analytics, and 2. I have never used, made, or touched a GWT project until now. I am trying to get google analytics to work with a GWT application. I read through this: How to integrate Google Analytics into GWT using the asynchronous script and the question that it links to with no luck.
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>
For my case, the project is large and I am not sure which html file I need to put the google analyics js in. I am assuming the html files in the war folder.
As for this bit:
call the new methods like so:
public static native void googleAnalyticsTrackPageView(String url)/*-{ $wnd.ga('send', 'pageview', url); }-*/;
I am totally unsure where I need to include this.
Oh, one last question. Is this still how I would test locally?
ga('create', 'UA-XXXX-Y', {'cookieDomain': 'none'});
Upvotes: 0
Views: 711
Reputation: 17489
In your war folder there should be an index.html or index.jsp file that serves the GWT JS file (xxx-nocache.js). You need to put the script there.
Alternatively you can also use Arcbee's universal-analytics library.
Upvotes: 1