What is “var _gaq = _gaq || []; ” for?

后端 未结 7 1162
梦如初夏
梦如初夏 2020-11-30 02:01

The Async Tracking code in Google Analytics looks like this:

var _gaq = _gaq || []; 
_gaq.push([\'_setAccount\', \'UA-XXXXX-X\']); 
_gaq.push([\'_trackPagev         


        
7条回答
  •  鱼传尺愫
    2020-11-30 02:51

    Yes, it ensures that _gaq is defined, so that _gaq.push() never fails.

    I would not mess with the name of the variables in GA's code... do you have any reason to? Does it conflict with any of your variables? (Then I would change mine...)

提交回复
热议问题