Wow.
I just put this
<script src='http://www.google-analytics.com/ga.js'
type='text/javascript'></script>
<script type="text/javascript">var pageTracker =
_gat._getTracker("UA-nnnnnn-n");</script>
in the index.html, and use this
public static native void urchinTracker(String pageName)
/*-{
$wnd.pageTracker._trackPageview(pageName);
}-*/;
to track it
Ian
http://examples.roughian.com
2008/10/1 [EMAIL PROTECTED] <[EMAIL PROTECTED]>
>
> On Sep 25, 9:51 am, Pete <[EMAIL PROTECTED]> wrote:
> > It seems like it should be possible to do something like this (see
> > below) to integrate the new ga.jsanalyticsapi. 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
> '[EMAIL PROTECTED]::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
> > '[EMAIL PROTECTED]::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.
>
> I have only investigated a bit, but the problem appears to be the GA
> code and the compiled GWT code stepping on each other. The solution I
> used was to just put the GA script tag in the host html (ignoring the
> business with http/https since I know the page will be only be
> accessed via http) -- if you are using the standard linker, the GWT
> code is isolated into an iframe -- and then reference it with the
> attached class. This is what I use for my own personal app and hasn't
> been tested outside my environment, is unsupported, etc etc. However,
> if you do run into problems with it let me know and I will see what I
> can do.
>
> I use trackPageview(String) to set fake URLs based on the history
> token, which I use to navigate the app. That way I can track the GWT
> app exactly the same as if it were static HTML.
>
> public class Analytics {
>
> /**
> * Create a new tracker object.
> *
> * @param key Google Analytics key
> */
> public static native void getTracker(String key) /*-{
> try {
> // handle GA included at the top level or embedded
> $wnd._pageTracker = (_gat || $wnd._gat)._getTracker(key);
> } catch (e) {
> // TODO(jat): anything better to do here than fake the tracker?
> }
> if (!$wnd._pageTracker) {
> // alert("creating fake tracker");
> // create fake object
> $wnd._pageTracker = {
> _initData: function() {},
> _trackPageview: function() {},
> _setVar: function() {},
> _addTrans: function() {},
> _addItem: function() {},
> _trackTrans: function() {},
> };
> }
> $wnd._pageTracker._initData();
> }-*/;
>
> /**
> * Track a pageview based on the current URL
> */
> public static native void trackPageview() /*-{
> try {
> $wnd._pageTracker._trackPageview();
> } catch (e) {
> }
> }-*/;
>
> /**
> * Track a pageview for a given event.
> *
> * @param event the name of the event to record, which must start
> with a slash
> */
> public static native void trackPageview(String event) /*-{
> try {
> $wnd._pageTracker._trackPageview(event);
> } catch (e) {
> }
> }-*/;
>
> /**
> * Set the segmentation variable.
> *
> * @param segment arbitrary string to identify the customer segment
> */
> public static native void setVar(String segment) /*-{
> try {
> $wnd._pageTracker._setVar(event);
> } catch (e) {
> }
> }-*/;
>
> /**
> * Build a transaction to be recorded.
> *
> * @param orderId
> * @param affiliation
> * @param total
> * @param tax
> * @param shipping
> * @param city
> * @param state
> * @param country
> */
> public static native void addTrans(String orderId, String
> affiliation, String total,
> String tax, String shipping, String city, String state, String
> country) /*-{
> try {
> $wnd._pageTracker._addTrans(orderId, affiliation, total,
> tax, shipping, city, state, country);
> } catch (e) {
> }
> }-*/;
>
> /**
> * Add a line item to an order. addTrans must have previously been
> called with the specified
> * orderId.
> *
> * @param orderId
> * @param sku
> * @param productName
> * @param category
> * @param price
> * @param quantity
> */
> public static native void addItem(String orderId, String sku, String
> productName,
> String category, String price, String quantity) /*-{
> try {
> $wnd._pageTracker._addItem(orderId, sku, productName,
> category, price, quantity);
> } catch (e) {
> }
> }-*/;
>
> /**
> * Track a transaction. addTrans and zero or more addItem calls
> must have been made previously.
> */
> public static native void trackTrans() /*-{
> try {
> $wnd._pageTracker._trackTrans();
> } catch (e) {
> }
> }-*/;
> }
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---