Home‎ > ‎UI‎ > ‎

Google Analytics


Script Include

  public void onModuleLoad() {
    setGaVars
();
    initGA
();
  }

 
private void initGA() {
   
Document doc = Document.get();
   
ScriptElement script = doc.createScriptElement();
    script
.setSrc("https://ssl.google-analytics.com/ga.js");
    script
.setType("text/javascript");
    script
.setLang("javascript");
    doc
.getBody().appendChild(script);
 
}

 
public static native void setGaVars() /*-{
    $wnd._gaq = $wnd._gaq || [];
    $wnd._gaq.push(['_setAccount', 'UA-26038145-1']);
  }-*/
;

Javascript Calls

Use this to trigger a page view. You could use the event too. 
 private static native void track() /*-{
    try {
      $wnd._gaq.push(['_trackPageview']);
    } catch (e) {
    }
  }-*/
;



Comments