February 12, 2013

Know Where Your Visitors Go To From Your Site | Outbound Links

|
If you still cannot understand all those tutorials about how to track all those outgoing or outbound links. Then you come to the right place.

Your default (meaning original setting) Google Analytics doesn't have this feature. You need to add a special code to your existing Google Analytics Tracking code.

1. For those using WordPresss, go to Appearance >> Editor. Then click on Header (header.php).

2. Look for your original Google Analtics code, which looks something like this:

<script type=”text/javascript”>

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-x']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
})();

</script>


3. Now what you need to do is is to add this additional code right below the above original code.

<script type=”text/javascript”>
var a = document.getElementsByTagName(‘a’);
for(i = 0; i < a.length; i++){
if (a[i].href.indexOf(location.host) == -1 && a[i].href.match(/^http:///i)) || a[i].href.match(/^https:///i))){
a[i].onclick = function(){
_gaq.push(['_trackEvent', 'outgoing_links', this.href.replace(/^http:///i, '')]);
}
}
}
</script>


4. Then click Update File button below.

To check your where your visitors have gone to, go to Google Analytics.

1. Click at Content.

2. Then click Events.

The info should be all there. Look for Event Category