June 2, 2011 Written by : Olaf
After your websites getting more pages and links, the chance that a visitor will follow a dead link to your site exists. If a visitor is trying to access a page on your site, the server will report (normally) a 404 error. The response is by default some unfriendly page with some spare information about the error which let most visitors stop visiting your site. But using the 404 error the right way, you the site owner can collect important information like:
* Of course the broken link or URL
* The HTTP_REFERER information where the dead link is available
* How often people try to access the bad URL
Using the right tools you’re able to turn 404 errors into a powerful resource:
* Provide a site search feature and let people search what they are looking
* Add advertisements to your error page and start earning money
* Learn about what people like to see on your site
In this tutorial we will show you how-to:
* Create a dynamic error page using the Google Site search and Adsense content ads
* Setup Google analytics to track 404 errors using a filter
* Set the site search feature with Google Analytics to collect the search queries from your visitor
With the Apache webserver it’s possible to use custom directives for your error script, place this code into your .htaccess file (place the file into the site root):
ErrorDocument 400 /error.php?err=400
ErrorDocument 401 /error.php?err=401
ErrorDocument 403 /error.php?err=403
ErrorDocument 404 /error.php?err=404
ErrorDocument 500 /error.php?err=500
Enable site search tracking in Google Analytics
The code for the error page is complete and we move to the last step: Tracking the site search queries from the error page. To do this we need to go in Google Analytics to the profile we created for the error page and click Edit (twice), check the setting Do Track Site Search, enter a “q” as the “Query Parameter” and click Safe Changes.