ga or _gaq.push for Google Analytics event tracking?

前端 未结 5 1345
有刺的猬
有刺的猬 2020-12-02 07:37

I would like to track an onclick of a button on a page on a site, after a condition is passed checking if a cookie is present.

Very simple but which syn

5条回答
  •  醉酒成梦
    2020-12-02 08:19

    If you use ga.js ("traditional" asynchronous code) you have to use _gaq.push. If you use analytics.js you need to use ga send. The methods are not interchangeable, they belong to two different versions of the Google Analytics tracking code.

    By now (2017) there is a new code version (gtag.js), so if you are using that you use neither ga nor _gaq.push but instead follow the migration guidelines to bring your code up to the latest version (or you quite sensibly start to use Google Tag Manager).

提交回复
热议问题