Pregunta

There are a million threads here on this and I've been through as many as I can muster and still can't get this working. I'm using GA's new tracking code, like so:

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'MYTRACKINGNUMBER', 'agoodman.com.au');
  ga('send', 'pageview');

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'MYTRACKINGNUMBER']);
  _gaq.push(['_trackPageview']);

</script>

On certain button-clicks, I want to track an 'event' in Google Analytics. For instance:

$("#freeTrial").on('submit', function(e){
        _gaq.push('_trackEvent', 'Signup', 'Free Trial Signup');
 });

However, this isn't working. I missed out on tracking 120 (important) events today alone so I'd really like to find out the best way to do this!

On the page in question I've tried checking _gaq in Chrome's console and it returns an arrayChrome console

Not sure how this affects things. When I click this button it becomes:

enter image description here

Perhaps I should be pushing an array into this array or something? Any ideas would be greatly appreciated!

¿Fue útil?

Solución

It looks like you're confusing the Universal Analytics (analytics.js) event syntax with that of the old Google Analytics (ga.js) event syntax.

Try updating your event on your form submit to the new syntax:

ga('send', 'event', 'Signup', 'Free Trial Signup');
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top