404 Error Page: Report, Monetize and Analyse

After your websites getting more pages and links, the chance that a visitor will follow a broken link to your site exists. If a visitor is trying to access a page on your site, your 404 error page should provide the visitor a “Not found” error. The response is by default some unfriendly page with spare information about the error which let most visitors stop visiting your website. By using these 404 errors the right way, it’s possible to 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 error page 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 Google 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:

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 broken links in Google Analytics

In case of a 404 error the page title on this custom 404 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:

404 Error Page

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 404 error page will look like:

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 404 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 404 error page is very basic and you need to integrate 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.

Related posts

7 Replies to “404 Error Page: Report, Monetize and Analyse
  1. 住宅樓宇按揭. 住宅樓宇按揭服務適用於購買一、二手物業或轉按,加上靈活彈性的還款期,全面滿足不同客戶的資金需要。 服務要點. 適用於一、二手物業或轉按,切合 …

  2. Derma Veil ® 被喻為新世代逆齡完美輪廓塑造,最新一代的PLLA膠原。 2003年獲得Mexican Ministry of Health (SSA)認證及美國FDA出口認證,並於2006年在拉丁美洲及遠東至東南亞地區廣泛使用,多個臨床實例見證能改善老化、遺傳、疾病(如脂肪萎縮)等引起的凹陷問題,其效果備受認同。蘊含兩大活性成分均具有生物兼容性及分解性,可逐步被人體自然分解吸收,有效塑造童顏肌 : 1. 聚左乳酸 (Poly-L-lactic acid / PLLA) : 促進骨膠原生長 2. 甘醇酸(Glycolic Acid ) 使皮膚表皮層黏膠性脂質鬆軟,改善皮膚厚度,加速細胞再生,減少皺紋及疤痕,加強保濕功能,增加光澤,美白效果。 由於甘醇酸分子較小,容易滲透皮膚 治療前: 皮膚的凹陷/皺紋 治療後: 成分被人體吸收、並刺激膠原增生,撫平皺紋及凹陷部位。 注入BOTOX(保妥適)會抑制突觸前膜釋放神經遞質,阻斷乙酰膽鹼(Acetylcholine)的釋放,從而使肌肉張力下降或癱瘓麻痺,皺紋也隨之而逐漸消失。合1子宮頸癌疫苗-Gardasil

  3. 又聞打玻尿酸造成失明 有關注射玻尿酸填補淚、眼袋手術、眼袋淚溝手術、眼袋、割眼袋、眼袋成形術、內開法脂肪下移筋膜修補等一些詳細敘述或似是而非或有爭議的事項。注射玻尿酸填補淚不是好選擇穿衣

  4. Nature`s Gate 天然之扉 【類醫學美容極緻有機系列】維他命C膚質調理晶乳 C for Yourself Vitamin C Texturizing Serum的商品介紹 Nature`s Gate 天然之扉,類醫學美容極緻有機系列,維他命C膚質調理晶乳 C for Yourself Vitamin C Texturizing Serum幼細

Leave a Reply