Apr26 |
Solve the parse error with Google Analytics |
Sorry for this first “nerdy” comment since we’ve set up this page, but the following error just made me nuts and looking for a solution on the net for hours. ;) I just wanted to save others the time by spreading this simple and quick solution. ;) If you don’t know what “Google Analytics” or a “parse error” is then just forget this post… ;)
If you get the parse error
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ‘,’ or ‘;’ in /www/htdocs/ on line …
after using Google analytics code on a php site with the echo command just change the third line of the Google analytics script from
document.write(unescape(”%3Cscript src=’” + gaJsHost + “google-analytics.com/ga.js’ type=’text/javascript’%3E%3C/script%3E”));
to
document.write(unescape(”%3Cscript src=\‘” + gaJsHost + “google-analytics.com/ga.js\‘ type=\‘text/javascript\‘%3E%3C/script%3E”));
Worked perfectly fine for me.

