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

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
add comment

2 Answers

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
add comment

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
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.