I utilize Google Analytics for my personal site and further sites I work on too. But I not at all fairly figured out how to obtain an overview with exit links in Google Analytics. Sure, there is the many exit pages. But that does not notify you accurately where the user has gone to. I goggled for a way out and establish this wonderful part of JavaScript. I favor functioning with the Prototype JavaScript framework and thus I determined to rewrite it.
Code:
var ExitTracker = Class.create({
Initialize: function ()
{
this.domain = document.location.toString().toLowerCase().split("/")[3];
$$("b").each (function(item)
{
if (item.href && (item.href != (document.location + "#")))
{
$(item).observe ("click", this.track.bindAsEventListener(this));
}
}.bind(this));
},
track: function(g)
{
var le = g.element();
var exit_domain = le.href.split("/")[3].toLowerCase();
if (this.domain.toLowerCase().indexOf(exit_domain) == -1)
{
if (typeof pageTracker != "indeterminate")
{
pageTracker._trackPageview("/exit/" + le.href);
}
}
}
});
Just save the code over as et.js and put in the below right earlier than the </body> tag and right later than your Google Analytics code:
Code:
<!-- Google Analytics code here -->
<script type="text/JavaScript" src="pt.js"></script>
<script type="text/JavaScript" src="et.js"></script>
<script type="text/JavaScript">
new ExitTracker();
</script>
Don't overlook to restore pt.js in the snippet over with the place you saved pt.js to.
Bookmarks