How to Track JavaScript Redirects through Google Analytics

by Peter Moorman on January 13, 2010

Remember this old adage?

I know half my marketing works, I just don’t know which half.

No longer true. You can now track how many people direct type your URLs.

In a past post I outlined how to set up 302 redirects, in this post I’ll show you the importance of JavaScript redirects in your marketing efforts.

You should set up JavaScript redirects to your landing pages if you fit the following criteria:

  1. You want to track how many people direct type in your domain. (302 redirects will not tell you this because the page doesn’t actually load.)
  2. You have several squatted domains that you would rather have directed to your home page or landing page
  3. You want to test the effectiveness of offline marketing efforts. For example, you buy an ad in a local magazine displaying a vanity url (dogwashingservice.com) and redirect the URL to your home page (dogwashing.com)

Here’s how to do it:

Pick the domain you want to host, then upload the file below (saved as index.php) to your domain’s file manager.

<html>
<head>
<script type=”text/JavaScript”>
<!–
setTimeout(“location.href = ‘http://www.yoursite.com’;”,1500);
–>
</script>

</head>
<body>

</body>
</html>

Now you have a JavaScript redirect. When visitors type in your site’s domain name, it will show up as a “Referring Site” in Google analytics.

Related posts:

  1. Was it Three or 3? A Quick Guide to Creating Domain Names with Numbers
  2. Faster Websites Lead to Higher Google Rankings: Accomplish Both with Thesis Theme and Bluehost

{ 2 comments }

Ben Waugh January 13, 2010 at 7:54 pm

I found your blog on google and read a few of your other posts. I just added you to my Google News Reader. Keep up the good work. Look forward to reading more from you in the future.

peterbmoorman January 14, 2010 at 3:17 am

Ben,
Thanks so much.

Comments on this entry are closed.

Previous post:

Next post: