Forum Moderators: coopster

Message Too Old, No Replies

Is there any way to find out what keyword a visitor used?

to get into my site through google?

         

jungle brother

12:19 pm on May 21, 2003 (gmt 0)

10+ Year Member



so if they searched for 'big smelly cheese' and then went to my site form that results page, i could then enter 'big smelly cheese' as a row into an SQL database? im only bothered about google.

BCMG_Scott

12:26 pm on May 21, 2003 (gmt 0)

10+ Year Member



It should be in your referer log information. When I go to google and search for "webmaster reference" Here is the URL:

[google.com...]

So if I click on one of the result links they should see a referer of the above URL. You can then just parse and split out the pieces that you want.

Scott Geiger

jungle brother

12:32 pm on May 21, 2003 (gmt 0)

10+ Year Member



i dont own the site and i dont know what a referer log is im afraid, im new to all this website lark. is there anyway for a php script to see what it is automatically?, could you explain it with some code please if you could :)

thankyou

jatar_k

4:08 pm on May 21, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I hope, at least, that you have access to the site.

For a description of Access Logs with Apache [httpd.apache.org].

as far as parsing the referer string to get the search phrase, maybe try either
String Functions [php.net]
or
Regular Expression Functions (Perl-Compatible) [php.net]

Timotheos

6:37 pm on May 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Any problems with using $_SERVER["HTTP_REFERER"]?

Shak

6:43 pm on May 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



i dont own the site and i dont know what a referer log is im afraid, im new to all this website lark

Thanks ever so much, really appreciate your confidence of the Web.

Shak

bonanza

6:54 pm on May 21, 2003 (gmt 0)



One way to do it:

First, get the querystring out of the $_SERVER['HTTP_REFERER'] variable. (see: parse_url [php.net])

Next, get the name/value pairs out of the querystring. (see explode [php.net])

Then, if there's an attribute named 'q', then that's your search string from google. If it's 'p', it may be from Yahoo's google search. Check the domain of the referer to be sure.

You may want to urldecode [php.net] the search terms once you've go them.

poluf1

9:03 pm on May 21, 2003 (gmt 0)

10+ Year Member



You can find plenty of (free) counters who also do this for you. Just plug in their code and you are set, you don't need any expertise at all.

As I remember perl's URI:Url also has a method that strist the keyword from a referer, although I never tried it.