Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I'm consulting on a web site which in order to provide clean URL's uses the 404 handler to catch what would otherwise be a 404 and serve the correct content.

In case that's not clear the 404 handler is being used to do what would otherwise be done by mod_rewrite.

So :

http://somedomain.com/fruit/apples/description

... does not exist on somedomain.com so the 404 handler, a PHP script, is invoked, parses the URL requested and then makes an internal requests for:

http://somedomain.com?foodtype=1&fooddesc=2&contenttype=3

The resulting content then gets sent but in doing so it reports a 404 to the user agent.

The client is interested in using Google Analytics in order to track usage of the site.

My question is will GA provide anything useful in terms of results or will the 404 being returned by the server cause GA to discard the response ?

share|improve this question
1  
In your script (404 handler) you need to explicitly send proper 200 response code if URL was successfully routed. This should override default 404 code. –  LazyOne Aug 4 '11 at 1:04
    
I'd make that an answer if I were you. –  paulmorriss Aug 4 '11 at 14:43
    
@LazyOne - thanks for being the original responder and pointing me in the right direction. –  shearichard Aug 7 '11 at 1:20
add comment

2 Answers

up vote 0 down vote accepted

What LazyOne said. Return a 200 from the handler. Otherwise GA will report it as a Page Not Found, which is what you are telling them anyways.

share|improve this answer
    
Thanks to you and LazyOne for useful answer. –  shearichard Aug 7 '11 at 1:17
add comment

Actually you don't need to do this, it's OK to return a 404. See the question about soft 404s here:.

You can return a 404 response code while serving whatever content you want.

And further down it says

your server should return a 404 if there’s nothing there to find

Sometimes the Google crawler looks for URL that are very unlikely to exist to see if you never return a 404. I suspect if you do never return a 404 they mark you down.

share|improve this answer
    
Thanks for response. I wasn't so in SEO rankings for this question as what the effect would be for Google Analytics, nevertheless it's an interesting side-effect of what the site is doing and the link you provide is very useful. Thank you. –  shearichard Aug 7 '11 at 1:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.