I have added this code in my blog for click tracking:
<script>
var trackOutboundLink = function (url) {
ga('send', 'event', 'outbound', 'click', url, {
'hitCallback': function () {
document.location = url;
}
});
}
</script>
<a href="http://www.example.com" onclick="trackOutboundLink('http://www.example.com'); return false;">Check out example.com</a>
But Google Analytics is not showing any click. Maybe code is not working properly.
Will you please suggest me the issue with the code?
Blog Url : http://beebom.com/
In your post here and on your example page, you used wrong quotation marks resulting in an error:
SyntaxError: illegal character
Change
<a href="http://www.example.com" onclick=”trackOutboundLink(‘http://www.example.com’); return false;">Check out example.com</a>
to
<a href="http://www.example.com" onclick="trackOutboundLink('http://www.example.com'); return false;">Check out example.com</a>
Don't forget to make the changes on all links on your website.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.