It seems like it should be possible to do something like this (see
below) to integrate the new ga.js analytics api.  However, when i did
it, all i got was trouble - very strange exceptions like

java.lang.RuntimeException: Could not find a native method with the
signature '@com.google.gwt.dom.client.Element::setInnerHTML(Ljava/lang/
String;)'
        at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.doInvokeOnWindow(ModuleSpaceIE6.java:
57)

or

203.1/com.google.gwt.user/com/google/gwt/core/client/GWT.java(216):
Failed to create JSNI method with signature
'@com.google.gwt.core.client.GWT::getVersion0()'

Can anyone shed light on why this is happening?

The error arose directly after calling new GoogleAnalytics(id) in my
onModuleLoad() method.   Note, the constructor for the GoogleAnalytics
object appears to succeed - but GWT is not happy after that call.

Am I doing something stupid here?

Thanks

-pete

import com.google.gwt.core.client.JavaScriptObject;

public class GoogleAnalytics
{
        JavaScriptObject tracker;

        public GoogleAnalytics(String key)
        {
                tracker = createTracker(key);
        }

        private static native JavaScriptObject createTracker(String key) /*-{
            if(!$wnd._gat)
            {
                var gaJsHost = (("https:" == $doc.location.protocol) ?
"https://ssl."; : "http://www.";);
                var blob = $wnd.unescape("%3Cscript src='" + gaJsHost +
"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E");
            $doc.write(blob);
            }
            return $wnd._gat._getTracker(key);
        }-*/;

        public void trackPageview()
        {
                trackPageview(null);
        }

        public native void trackPageview(String url) /*-{
        
[EMAIL PROTECTED]::tracker._trackPreview(url);
        }-*/;

        public void trackEvent(String category, String action)
        {
                trackEvent(category, action, null, null);
        }

        public native void trackEvent(String category, String action, String
label, Integer value) /*-{
        
[EMAIL PROTECTED]::tracker._trackEvent(category,
action, label, value);
        }-*/;
}


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to