Funny, I was running into similar questions earlier today.
1) The document.write() thing is a common problem. I don't see any
practical benefit to setting the MIME type to xhtml+xml in my apps and
that is what causes document.write() to not work, so I just told lift
to use a plain html mime type. You can do that by adding this to your
Boot class:
LiftRules.useXhtmlMimeType = false
So that is another option for fixing the problem with Google Analytics
(and other things, like Google AdSense)
2) If you only want the analytics code to show up in production, there
isn't a <lift:production /> tag that I'm aware of, but there still is
a pretty easy way to do it. Just make the analytics code a snippet and
use the run mode stuff in Lift to only show the snippet in production.
It would look something like this:
def analytics(in: NodeSeq) : NodeSeq =
net.liftweb.util.Props.productionMode match {
case true => <real analytics code here />
case false => <!–Analytics Code Goes Here–>
}
Then just make sure that your production server is setting the
run.mode property to 'production'. I actually wrote up a short blog
post on this stuff today if you want to know more:
http://www.spenceruresk.com/2009/07/14/using-run-mode-and-properties-in-lift/
- Spencer
On Jul 14, 8:25 pm, Xavi Ramirez <
xavi....@gmail.com> 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:
> <script src="
http://www.google-analytics.com/ga.js" type="text/javascript" />
> <script type="text/javascript">
> //<![CDATA[
> try { var pageTracker = _gat._getTracker("UA-4384857-1");
> pageTracker._trackPageview(); } catch(err) {}
> //]]>
> </script>
>
> A full write up of my experiences with Google Analytics and Lift can
> be found here:
http://www.the-xavi.com/articles/operation-is-not-supported-code-9
>
> ~Xavi
>
> On Tue, Jul 7, 2009 at 4:34 PM, Xavi Ramirez<
xavi....@gmail.com> wrote:
> > Thanks! I ran into this exact problem. Is there any way to get rid
> > of it? Is there a <lift:production> tag?
>
> > Thanks,
> > Xavi
>
> > On Tue, Mar 17, 2009 at 5:22 PM, Charles F. Munat<
c...@munat.com> wrote:
>
> >> OK, I have to stop posting this crap when it's 5:30 AM, I've been
> >> working for 18 hours straight, and my brain is fried.
>
> >> The problem was that I was looking at it on my development machine, not
> >> the production server. The Google Analytics code is tied to the URL. If
> >> the URL is wrong, it doesn't serve the script, so Firebug reports the
> >> error. I are dumb.
>
> >> Hopefully, though, my posting this will save some other person a hassle
> >> and a little public embarrassment.
>
> >> Chas.
>
> >> Derek Chen-Becker wrote:
> >>> Can you send the beginning of the XHTML output, up to and including the
> >>> GA script?
>
> >>> Derek
>