Google analytics in haml

Apr 2011

This is the new (as of writing) google analytics code in HAML.

Remember to swap the YOUR_CODE with your google UA number.

:javascript
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', YOUR_CODE']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script');
    ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.