Wednesday 12 February 2014

How to find a Broken Backlink? The 404 Analysis Method

You may ask a client, supplier, blogger or whatever to add a link to one of your pages to get some link juice or referrals, but they may do a typo and add a wrong link URL to your site that when clicked it ends visitors up on a 404 not found page. So, how can you know those bad links?!


Here are some ideas to track those links and report them:

1- In the header template of your 404 page, find this line in your Google Analytics Tracking Code: _gaq.push(['_trackPageview']); Then change it as follows: _gaq.push(['_trackPageview','/404error/?url=' + document.location.pathname + document.location.search + '&ref=' + document.referrer]); What's happening here is we're creating a virtual pageview that starts with /404error/ (you can name it anything you want) and then appending 2 made-up parameters to help us spot the source of the problem:
  • · "url=" will catch the URL which a visitor attempted to access. 
  • · "ref=" will catch the referring page. 
Here's what it will look like in your reports (when you do a search for "404error")



2- Another way is use Raven's GA Config tool. Simply add your GA account number then copy the Google Analytics tracking script just before the </head> tag on your 404 page (not your entire website). 
The code will be like this:

Asynchronous

<script type="text/javascript">
  var _gaq = _gaq || [];
 _gaq.push(['_setAccount', 'UA-XXXXX-X']);
  _gaq.push(['_trackPageview', '/404.html?page=' + document.location.pathname + document.location.search + '&from=' + document.referrer]);

  (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>

Traditional ga.js

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? " https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + " google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try{
var pageTracker = _gat._getTracker("UA-XXXXX-X");
pageTracker._trackPageview("/404.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer);
} catch(err) {}
</script>

3- More ways:
http://ralphvanderpauw.com/digital-analytics/google-analytics-best-to-track-404-error-pages/