Google event tracking not working with new style tracking code
I don't seem to be able to get Google analytics event tracking to work
with the "new" style tracking code.
I cobbled together this code, but it might be wrong:
<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-42805759-5', 'my-domain.com');
ga('send', 'pageview');
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-42805759-5']);
_gaq.push(['_trackPageview']);
</script>
And an example link is:
<a href="my-page.aspx" onclick="_gaq.push(['_trackEvent', 'Link click',
'My page clicked', 'Something']);">View this page</a>
Should this work? And also, should tracked events be visible in Real-time
> Events area of the dashboard?
Thanks.
No comments:
Post a Comment