Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get the Full URL of the Referring or Previous Page  RSS feed

 
Craig Golby
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, having trawled the net, I cant find an absolute answer ... ... so am hoping you can help.

I am building a corporate web site that has a variable strap line / message on the home page. At the moment the message is randomly generated and may not therefore relate to what a visitor is interested in.

What I want to do is examine the URL of the referring page to see if there are any clues as to why the Visitor has come to the site, and if there are to present them with a suitable message pointing them in the right direction.

I have tried request.getHeader("referer"), but this only seems to work for internal links and not for links in from say a Google Search.

So for instance, if we were able to pick up the following URL "http://www.google.co.uk/search?hl=en&source=hp&q=staplers&btnG=Google+Search&meta=&aq=f&oq=", then we could detect the word "staplers" in the middle and present a message relating to Staplers to the Visitor.

No I don't sell Staplers, it was the first example that came to mind !!!

This must at least be partially possible, as Google Analytics for instance is able to tell me the Root URLs that everyone has come from.

So how do I get the Full URL of the Previously visited page ?
 
efehan durgun
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My firend, I hope you can solve this problem.oyunlari 1 oyun
 
James Ward
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about doing this with javascript:

document.referrer

More info:
http://www.netmechanic.com/news/vol4/javascript_no14.htm
 
Craig Golby
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Efehan.

James, I had seen this, but had dismissed it as it didnt seem to work. Having read the article that you referenced that is likely because I was testing it locally and not within a proper Web Server environment.

Before I go too far down this path, do you know if this will return the full URL i.e. "http://www.google.co.uk/search?hl=en&source=hp&q=staplers&btnG=Google+Search&meta=&aq=f&oq=" or a shortened URL of "http://www.google.co.uk" ??

Not a problem if you dont know, I can test it by letting the page store away the results for a few weeks and see what we get !!! Will probably do this anyway in order to figure out how people are getting to us.


 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!