Ever wanted to use Piwik on your GWT enabled sites? This library implements a java class for GWT allowing you to use Piwik functionality such a recording page hits, outbound link clicks and goals.
For now it is a simple wrapper around the piwik.js javascript, however, if time permits i’ll write a GWT java based implementation. The wrapper is written in such a way that it will inject the piwik.js javascript from the GWT javascript without loading it from the server serving the page, saving one round trip over a seperate GWT+Piwik approach.
All the functions available from piwik.js are now available from the com.xind.gwt.piwik.client.Piwik interface. Using the library is very similar to how Piwik is called from javascript:
Piwik piwik = new PiwikImpl(<piwikId>,<url to Piwik.php>);
piwik.trackPageView();
piwik.enableLinkTracking();
Have not thoroughly tested all functions but the basics should be working fine. If not, do let me know.
The library is released under the GPL v3 license and currently supports Piwik release 0.99.
Although the DOM implementation in GWT is very good, one function that I personally use a lot has been missing since the beginning and is also not expected to be there in release 2.1, getElementsByClassName.
The function is similar to getElementsByTagName, but instead of matching all elements against the tag name (e.g. A, DIV) it matches against one or more CSS class names. In all modern browsers this function is implemented natively in the JavaScript document object. Quirksmode provides a good list on which browsers implement this and which do not.
In my library the function is in the com.xind.gwt.dom.client.DOM class, which has a generic implementation and specialized ones depending on the browsers capabilities. The generic implementation tests for the existence of the native function and uses it if available, if not, it uses a JavaScript implementation of it. For Internet Explorer the implementation never checks for the native function as no version implements it at this point.
Include the library in your build path and make sure you inherit the following module in your applications XML configuration file:
<inherits name=”com.xind.gwt.dom.DOM”/>
The library is licensed under the Apache License, Version 2.0 just like most of GWT. A copy of which can be obtained here.
As I use this library in my own projects, most of the testing has gone into my specific scenarios, do let me know if you find any issues.
The library can be downloaded here: