Google Analytics のエラーについて

2009-09-29 20:52 JST @sadayuki

の直前に入れるようにとの指示だったので、promenade.tmplの当該箇所にjavascriptを入れたのだが、アクセス件数が0のまま。確かに下がりはするだろうと思うが、さすがに0は無いだろうと思う。何かエラーが発生しているはずだと思ってFirebugでデバッグしてみる。"Operation is not supported" code: "9 とかエラーで出ている。Google先生に聞いてみると、ドンピシャの記事が見つかる。

Actually, I was completely wrong! Turns out that the error occurs because the Google Analytics snippet relies on document.write(). Unfortunately XHTML does not support document.write() [1], and it seems firefox is one of the few browsers that respects this constraint.

I ended up "hacking" the default google analytics snippet into something like this:

FYI, the example above does not work on secured pages.

XHTMLではdocument.write()は使えません、とのこと。早速教わった通りに変更してみました。どうでしょうかね。

Amazonのjavascriptも同じエラーだったのですが、src指定された先のscriptでエラーが発生しているので、まずは諦めることにしました。

同様に、