lauantai 10. heinäkuuta 2010

Google Analytics and Illegal Character Error on Firefox

This time in English. I had a problem on our website Silverbank that on the statistics there were many visitors but none of them was using Firefox. Strange.

I noticed that Firefox error console shows an error "Error: illegal character
Source File: http://www.google-analytics.com/ga.js" and therefore no Firefox visitors are counted. A quick search shows that some other people have also this problem but no one has solved it (or I was not searching well enough).

I figured out that by changing the file encoding from utf-16 to utf-8 the problem disappears. The reason is that Google Analytics code snippet is not working if the page is accidentally saved with utf-16 -encoding. Here is an example of "wrong" encoding:


Just save the file with utf-8 instead of utf-16 and the code will work. If you are not using Firefox, you can check the encoding with the Validator (while writing this post, the validator shows the encoding is "utf-16le" and the analytics code is not working on Firefox).

Ei kommentteja:

Lähetä kommentti