GA Event Tracking from localhost

梦想的初衷 提交于 2019-12-01 13:33:41

Try put this line before the first pageview:

_gaq.push(['_setDomainName', 'none']);

Your tracker will be similar this:

<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12345-1']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_trackPageview']);
</script>

This option works directly with the cookie configuration, so use only for locahost!

The New "Universal Analytics" API

Google is transitioning everyone over to a new system and you probably already have the new code snippet in your pages. They have changed many of the APIs including the event tracking.

Make sure you use this call after the main snippet

ga('create', 'UA-XXXXXXXX-X', {
  'cookieDomain': 'none'
});
ga('send', 'pageview');

Again this option works directly with the cookie configuration, so use only for localhost!

There is a thorough blog post on the subject http://blog.tylerbuchea.com/tracking-events-in-googles-new-universal-analytics/

And here is the official Google documents on the new API https://developers.google.com/analytics/devguides/collection/analyticsjs/events

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!