Tuesday, July 7, 2009

Grails Google Analytics Plugin



As Marc Palmer already mentioned it's important for the community to download and test Grails 1.2-M1.

I've already started with 1.2-SNAPSHOT builds for my home project but also decided to write a simple Google Analytics plugin and test the plugin development parts of Grails 1.2-M1. Again, it is a very simple plugin but found no blocking issues so far.

About the plugin: It includes a simple tag to embed the Google Analytics tracking code in your views/layouts. Just add <ga:trackPageview /> just before your closing </body> tag and add your Web Property ID to Config.groovy:

// grails google analytics plugin configuration
google.analytics.webPropertyID = "UA-xxxxxx-x"


By default only running your Grails application in production mode the Google Analytics tracking code will be outputted. This makes sense as you don't want to mix development or testing page hits with the ones from production. However if you need you can explicitly enable/disable Google Analytics or use different Web Property ID's per environment. See http://www.grails.org/plugin/google-analytics for details.

No comments: