I'm a bit late to this thread, but found it really useful.
In case this is of any use to future explorers of the thread, I
thought I'd contribute what we ended up doing: we put
(snippet below) before in our
template. I guess this may have been all over-taken by the lift:tail
work.
--
import scala.xml.NodeSeq
import net.liftweb._
import http._
import S._
import util._
import Props.RunModes._
class Analytics {
// To avoid non-XHTML compliant JavaScript we decide if we're https
or not here.
// See e.g.,
http://happygiraffe.net/blog/2009/06/06/google-analytics-in-xhtml/
def google_script_url = S.request match {
case Full(req) if req.request.scheme == "https" =>
"https://ssl.google-analytics.com/ga.js";
case _ => "http://www.google-analytics.com/ga.js";
}
// Output the Google Analytics JavaScript
def google(xhtml: NodeSeq) = Props.mode match {
case Production | Pilot | Staging =>
++
case _ => Nil
}
}
---
...but replacing 'UA--1' with your tracking code.
Warning: I've not tested with a https site yet.
Richard
On Wed, Jul 15, 2009 at 3:25 AM, Xavi Ramirez wrote:
>
> Sorry, I didn't replay earlier, but it turns out that the "operation
> is not supported code: 9" error is related to the fact that the
> default Google Analytics snippet uses document.write(). It turns out
> that XHTML does not support document.write(), which causes Firefox to
> chock.
>
> Ultimately, I replaced the default Google Analytics snippet with this one:
> http://www.google-analytics.com/ga.js"; type="text/javascript" />
>