Back in March, I moved some code to the main JavaScript of this blog, which is about the 404 tracking. The code was exactly as follows:


var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
_gaq.push(['_trackEvent', 'Error', '404']);

I was unaware of that _gaq was a subject of being minified, actually had never given a thought about minimization. However, I did notice that it’d been weeks there was always being zero errors reported via weekly report email. I was lazy and foolishly thought my blog indeed had no more visitors suffer from 404 pages.

Until moments ago, I got another report with no errors. I decided to check up on the issue, facing the reality. It turned out the first line of code was minified like:


J=J||[];

That told me I was just being silly to dream about there was no 404 actually occurred.

My resolution is to explicitly use window to access _gaq:


var _gaq = window._gaq || [];

It is minified as


g=window._gaq||[];

There must be some good practice on how to use global variable, now I would be more careful when using minifier. Lesson learned.