Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On my website, I track when users click on a search result that brings them to a details page for an item. I then save what search query they used before they clicked.

My current solution is this:

  1. Each link in search results is in the form /goto/<item_id>/?search_id=...
  2. /goto/<item_id>/ saves that a user used a given search id to get to a given item, and then returns a 302 redirect to /details/<item_id>/
  3. /details/<item_id>/ displays the details page and does not do any tracking.

For the users, everything works fine, but when I check Google search results for my page, the direct links to the details page URLs say /goto/<item_id>/?search_id=... with some old search_id, instead of /details/<item_id>/.

I feel like I'm missing an obvious solution :) The only thing I came up with so far is using /details/<item_id>/ links in HTML and using JavaScript to replace them all with /goto/<item_id>/search_id=..., but that seems like an overkill.

Any better ideas?

share|improve this question

I finally found the answer. Google caches:

  • the URL you redirect FROM if you use a 302 (temporary) redirect
  • the URL you redirect TO if you use a 301 (permanent) redirect

So I only had to change 302 to 301 to correct my site's Google search results.

share|improve this answer

seo redirects trackingession variable with the search query?

Then, once on your item detail page, you write in your database the item id and the query.

This way, you don't need the javascript magic and the redirect page.

Hope this helps

share|improve this answer

Your Answer


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.