title: Integrating Google Analytics into GWT application
body: <p>This should be totally simple but I can't get it working no matter what I try. I'm trying to use Google Analytics with GWT application. From what I understood, there are two way to do it:</p>
  
  <p>First is synchronous, by inserting tracking code at the end of &lt;head&gt; section HTML page and then calling this method:</p>
  
  <pre><code>public static native void recordAnalyticsHit(String pageName) /*-{
      pageTracker._trackPageview(pageName);
  }-*/;
  </code></pre>
  
  <p>Second is asynchronous, by inserting tracking code just after &lt;body&gt; tag and then calling this method:</p>
  
  <pre><code>public static native void recordAnalyticsHit(String pageName) /*-{
      _gaq.push(['_trackPageview(' + pageName + ')']);
  }-*/;
  </code></pre>
  
  <p>When running each of those methods, however, I get this exceptions in hosted mode:</p>
  
  <pre><code>[ERROR] [myproject] Uncaught exception escaped
  com.google.gwt.core.client.JavaScriptException: (ReferenceError): pageTracker is not defined
  
  [ERROR] [myproject] Uncaught exception escaped
  com.google.gwt.core.client.JavaScriptException: (ReferenceError): _gaq is not defined
  </code></pre>
  
  <p>When observing site in Firebug, I see that ga.js gets loaded, but that's about it.</p>
  
  <p>Did anyone get Analytics working with GWT? Also, does _gaq accept page name as trackPageview parameter, since all the examples I've seen use this call:</p>
  
  <pre><code>_gaq.push(['_trackPageview()']);
  </code></pre>
  
  <p>(Of course, that also doesn't work for me.)</p>