sim.plified.com

Chris Pollock

Chris Pollock - web developer & ecommerce entrepreneur
undivided… my thoughts on world, family, church, business, technology and Jesus Christ (all in all)

Track 404 Errors with Google Analytics

Tracking 404 pages is a part of being a web master. I was using a service called Link Patch, but they recently shut down. Why this never occurred to me before I don't know, but I thought, why not just track 404s as an Event in Google analytics. I tried it and it worked like a charm.

Here is the code I placed on my 404 page:


<script type="text/javascript">
	// log 404 in google analytics
	_gaq.push(['_trackEvent', 'Error', '404', '<?php echo $_SERVER['REQUEST_URI']; ?>']);
</script>

This will place the url for the page in the events menu under the "Error" category

What I love about this approach is that:

  • Groups multiple errors together to help me track trends
  • Allows me to filter and get reports across date ranges
  • Get reports emailed to me on a weekly, monthly, quarterly or yearly basis

I think this is going to be a great shift. I just sorry I didn't set it up earlier!

  • http://www.brightwurks.com Nick Francis

    Hey Chris! First off, thanks for being a Linkpatch user … sorry we decided to shut it down. Your solution is brilliant. We'll be sharing it with some of our other past customers. Thanks for blogging about it.

  • Pingback: Lesezeichen vom 28.01.2011 | Doc-T @ BlackRealm

  • http://www.vivaperformance.com George

    Hi Chris,

    I added the script to my 404.html page, but am having trouble seeing events getting logged for our website on Google Analytics. Am I missing something? The script code was added before the html code. Thanks for your help!

  • http://web.simplifiedbuilding.com cwpollock

    Hi George, is your google analytics code also on your 404 page. The standard google tracking code needs to be installed on the page as well.

Things I see

Day 2: the back yard is swarming with fluffy tailed rodents. The boys are delighted. There is ample GoPro footage of inquisitive squirrel faces. Caleb was even hand feeding. #lifewithboysOwl pellet dissection is an interesting experience!! It was almost like archaeology, but different in the “this was puked up by a bird” kind of way :stuck_out_tongue:. #lifewithboys #owlbranddiscoverykits #biologyDoes baiting squirrels with Cheerios and observing their behavior count as biology? We are studying mammals after all. :smile:#citysquirrels #lifewithboys #backyardwildlifePhotoSushi for 9 courtesy of @amylpollockSomewhere, deep down inside, I’m thankful that they can cook their own breakfast:raised_hands:. But parenting is filled with such conflicting emotions. :yum: #lifewithboys #cleanupyourmess #wafflesShearing my sheep today :sheep:! #lifewithboys #This is for my friends who don’t live in upstate ny #snowCaleb’s birthday lunch. Now I have two teenagersBeautiful upstate NY #home#Repost @andrewpetersonmusic ・・・ The Burning Edge of Dawn is on sale for $5.99 through this Thursday, anywhere you buy music online!Classic PhotoDinner with the Jobs :grinning:Worn down by the world.

Chris Pollock

Web Developer - proficient in both PHP and ASP.NET.
Rochester, New York

View my web developement site.

View Chris Pollock's LinkedIn profile

My Pictures

Day 2: the back yard is swarming with fluffy tailed rodents. The boys are delighted. There is ample GoPro footage of inquisitive squirrel faces. Caleb was even hand feeding. #lifewithboysOwl pellet dissection is an interesting experience!! It was almost like archaeology, but different in the “this was puked up by a bird” kind of way :stuck_out_tongue:. #lifewithboys #owlbranddiscoverykits #biologyDoes baiting squirrels with Cheerios and observing their behavior count as biology? We are studying mammals after all. :smile:#citysquirrels #lifewithboys #backyardwildlifePhotoSushi for 9 courtesy of @amylpollockSomewhere, deep down inside, I’m thankful that they can cook their own breakfast:raised_hands:. But parenting is filled with such conflicting emotions. :yum: #lifewithboys #cleanupyourmess #wafflesShearing my sheep today :sheep:! #lifewithboys #This is for my friends who don’t live in upstate ny #snowCaleb’s birthday lunch. Now I have two teenagersBeautiful upstate NY #home#Repost @andrewpetersonmusic ・・・ The Burning Edge of Dawn is on sale for $5.99 through this Thursday, anywhere you buy music online!Classic PhotoDinner with the Jobs :grinning:Worn down by the world.