Question

My code is using the new Universal GA code, with ga(send syntax, as follows:
<td id="newevent" onclick="ga('send', 'search-result', 'click', 'EVENTNAME');" ></td>. I am using the Universal GA JS code in my section.

<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!-- Google Analytics -->
<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-XXXXXXX-A');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->
</head>
<body>

<a href="#" id="ec-search-result" onClick="ga('send','EVENTNAME','CATNAME','ACTION');">TEST</a>
</body>
</html>

However, no event hits are registered in the GA Dashboard. Please advise.

Was it helpful?

Solution

I think you have made a small mistake in your cording. See you are sending the message, but with out saying what is executing. You are missing “event” part in your code

New Code :

ga('send', 'event', 'search-result', 'click', 'EVENTNAME');

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top