Events not being tracked in new Google Analytics (analytics.js) setup -


i have website using new universal analytics (analytics.js) track. setup , working (pageviews, referrals, etc.) using following code snippet:

<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', 'ua-39570713-1', 'site.com');   ga('send', 'pageview');  </script> 

that located before </head> tag.

i using jquery fire off event. tested jquery alert message , getting called, isn't problem. here snippet fires when button clicked:

$('#submitbutton').on('click', function() {       ga('send', 'event', 'button', 'click', 'contact form');     }); 

nothing appearing in events section of analytics. keep clicking button, different computers make sure isn't excluding ip address. because analytics doc google provides not provide whole lot of explanation i'm @ loss here.

if using google tag manager , want trigger events via code, ga('send'...) not appear enough. need first fetch appropriate analytics object:

if ("ga" in window) {     tracker = ga.getall()[0];     if (tracker)         tracker.send("event", "test", "test ga"); } 

note assumes you're using single google analytics tracking code on site. if happen using multiple, may need fetch appropriate 1 name or index.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -