Pages

Sunday, August 1, 2010

404 Errors: Report, monetize and analyse

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

Error reporting page

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

We use for the custom error script the most common HTTP errors.
Next we need to create a PHP script called error.php which can handle the different errors:

$errorNum = (int)$_GET['err'];
$err_str = array(404=>'Not Found', 400=>'Bad Request', 401=>'Unauthorized', 403=>'Forbidden', 500=>'Internal Server Error');
echo '



'</span><span style="color: rgb(51, 153, 51);">.</span><span style="color: rgb(0, 0, 136);">$err_str</span><span style="color: rgb(0, 153, 0);">[</span><span style="color: rgb(0, 0, 136);">$errorNum</span><span style="color: rgb(0, 153, 0);">]</span><span style="color: rgb(51, 153, 51);">.</span><span style="color: rgb(0, 0, 255);">'



An error occured: '.$err_str[$errorNum].'

    '; ?>
This script will show the different errors and also some advertisement if you add the ad code. Don’t forget to add the GA code snippet.

Track dead links in Google Analytics

In case of a 404 error the page title on this custom error page will be “Not Found”. We use the page title as a filter in Google Analytics to track the page views. Create a new profile for the site you’re working on and add this filter:

Adding Google Site Search to your 404 error page

If you haven’t done yet, create a Google site search for your website. Add only your own website to the list of searched sites and don’t search the entire web. Add your Google Adsense ID (section “Make Money”) and head to the section “Look and feel” and select the option Iframe. Choose a style for the search form / result and maybe you like to customize the style. Push now the button “Get code” (or enter the section “Get code” from the sidebar) and enter there the URL from your error page.
Copy / paste the code for the search form and the results into the body section from your error page. Your completed page will look like:

$errorNum = (int)$_GET['err'];
$err_str = array(404=>'Not Found', 400=>'Bad Request', 401=>'Unauthorized', 403=>'Forbidden', 500=>'Internal Server Error');
echo '



'</span><span style="color: rgb(51, 153, 51);">.</span><span style="color: rgb(0, 0, 136);">$err_str</span><span style="color: rgb(0, 153, 0);">[</span><span style="color: rgb(0, 0, 136);">$errorNum</span><span style="color: rgb(0, 153, 0);">]</span><span style="color: rgb(51, 153, 51);">.</span><span style="color: rgb(0, 0, 255);">'



An error occured: '.$err_str[$errorNum].'

   
';   if (empty($_GET['q'])) { // show the ad only if there is no search echo ' '; } echo ' '; ?>
We placed the add code also into some IF clause, because there should not be another Google Adsense advertisement beside the Google ads from the result page.

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.
This error page is very basic and you need add your sites web template to make it complete. If you like this tutorial and you have used the code on your own site please share the URL to your new or updated error page. Even if you don’t like to use the code from this page, we advice to track the errors and also the site search queries from your visitors. If you have questions or comments please post them below.

0 comments:

Seo | Web Design | Web Development | Link Building | Web Maintenance | CMS | Shopping Feeds | E-commerce | Corporate Identity | Web Application Solutions | Web Programming | Web Marketing | Flash Design | Brochure Design | Content Writing | Ultimate Solution | Content Identity | Support | Outsourcing | Portfolio | Testimonials | SEO Plans | SEO Packages | Internet Marketing Strategy | Site Optimization & Maintenance | PPC Management Services | Web Design Company Chennai | Privacy Policy | Term of Service | Copyright


Ultimate Creators is an innovative web design Company Chennai Specializing in Web Designing, Logo Branding,Search Engine Marketing, Search Engine Promotion and Search Engine Ranking Services

Ultimate creators is the height of creativity when it comes to web designing, logo branding with a touche of excellence added to your product you can be assured of the ultimate creation in the World Wide Web. If you wish to market yourself in the web you can opt for the seo package which provides you with the options of search engine marketing, search engine promotion and search engine ranking services. For ultimate creations look no further than ultimate creators