Current location: Hot Scripts Forums » Programming Languages » PHP » Google Questions Log


Google Questions Log

Reply
  #1 (permalink)  
Old 08-02-06, 08:12 AM
Barnz1986 Barnz1986 is offline
Aspiring Coder
 
Join Date: Jan 2006
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
Google Questions Log

Hello,

I want to make a google questions log meaning everytime a user enters my site from google, it will record the search query which the user entered into google.

http://www.google.com/search?hl=en&q=test

I want it to get the value of "q", I thought about using GET but I do not think it will work because it will not be part of the URL when the user actually enters my page (it will only be on the previous page "Google").

How can I do this? Could I use the REFERER variable or does that only get the URL up until the file extension, .php, .html etc. And not the whole URL including all the vairables etc.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 08-02-06, 08:48 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
Give this a try.

PHP Code:



parse_str
($_SERVER['HTTP_REFERER'], $res);
    
echo 
$res['q']; 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 08-02-06, 01:53 PM
Barnz1986 Barnz1986 is offline
Aspiring Coder
 
Join Date: Jan 2006
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by nico_swd
Give this a try.

PHP Code:



parse_str
($_SERVER['HTTP_REFERER'], $res);
    
echo 
$res['q']; 
Hello nico,

I tried it but it did not work, I also tried just echo`ing the $_SERVER['HTTP_REFERER'] and it did give the URL but without all the variables on the end of it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 08-02-06, 02:00 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
Hm, weird. I've tried it and it works for me. May depends on your browser?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 08-03-06, 10:42 AM
Barnz1986 Barnz1986 is offline
Aspiring Coder
 
Join Date: Jan 2006
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by nico_swd
Hm, weird. I've tried it and it works for me. May depends on your browser?
Ill try it again, are you sure the HTTP_REFERER gives the variables on the end of the URL?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 08-03-06, 11:15 AM
Richard's Avatar
Richard Richard is offline
Wannabe Coder
 
Join Date: Sep 2005
Location: Oxford, UK
Posts: 239
Thanks: 0
Thanked 0 Times in 0 Posts
According to PHP.net, the predefined variable 'HTTP_REFERER' isn't reliable, and it states
Quote:
"Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted."
However, there is a user comment on the same page that supplies an alternative, found here. Not sure how well it'll work, but might be worth a try if you're having trouble with the referer veriable.
__________________
Richard.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 08-03-06, 07:03 PM
Barnz1986 Barnz1986 is offline
Aspiring Coder
 
Join Date: Jan 2006
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Richard
According to PHP.net, the predefined variable 'HTTP_REFERER' isn't reliable, and it states However, there is a user comment on the same page that supplies an alternative, found here. Not sure how well it'll work, but might be worth a try if you're having trouble with the referer veriable.
Hello Richard,

I will give that a try, I am definitly having trouble with the REFERER variables as it is only showing the URL and not all the extra variables on the end of the URL.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get Indexed in Google Quickly rorycanyon General Advertisements 3 03-21-07 10:11 AM
Google (DO EVIL)! spydb The Lounge 6 06-19-06 06:22 PM
Google is going to take over the world iddx The Lounge 24 05-23-05 01:58 PM
Questions Script ... gillweb Job Offers & Assistance 0 02-08-05 03:14 PM
Google Bot Problem eddyvlad The Lounge 2 01-14-05 12:26 PM


All times are GMT -5. The time now is 12:17 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.