Google’s Help for your 404

7 May 2009 by TQuizzle, 2 Comments

So you’re already ahead of the game by having a good 404 page, right? Good, now you can even add a bit more spice to them.

While on Google’s Webmaster Tools page, I noticed this little gem:
<script type="text/javascript">
var GOOG_FIXURL_LANG = 'en';
var GOOG_FIXURL_SITE = 'http://www.mydomain.com';
</script>
<script type="text/javascript" src="http://linkhelp.clients.google.com/tbproxy/lh/wm/fixurl.js"></script>

Since users need to find what they’re looking for within 7 seconds to avoid them leaving your site…use this little guy to help out. It will make it easier for them to find the information they’re looking for. So, you’re probably wondering, “What does that do to help me?” Good question, here’s a rundown of what Google says:

  • It adds a search box for your site with appropriate search suggestions.
  • It tries to provide alternatives to incorrect URLs.


So to make this thing a little more WP friendly, I added the <?php bloginfo('url'); ?> to that GOOG_FIXURL_SITE variable in the script and shebang, it’s working like a charm. Now, add it to your 404.php file in your template directory and users might thank you.

Here’s what it should look like sitting in your 404.php file:
<script type="text/javascript">
var GOOG_FIXURL_LANG = 'en';
var GOOG_FIXURL_SITE = '<?php bloginfo('url'); ?>';
</script>
<script type="text/javascript" src="http://linkhelp.clients.google.com/tbproxy/lh/wm/fixurl.js"></script>

If you really want to tweak how this gadget looks, Google’s provided custom classes that its script uses to give you full customization.

Do you like?

Related posts:

2 Responses to “Google’s Help for your 404”

  1. nancy 9 May 2009 at 10:26 pm #

    What can you do if you feel like google is giving inappropriate searches (as in all porn searches since my website is named bitch about eay, i suppose). Also I can’t replace it with any other 404 – it’s like it won’t give up control… maybe I just don’t know what I’m doing… any help is appreciated.

    • TQuizzle 22 May 2009 at 1:01 pm #

      I’d contact Google about it. I doubt they’d give you much help considering the type of website you author, but you never know. They might surprise you.


Leave a Reply