Page 1 of 1

Captured Searched Terms with PHP?

Posted: Fri Sep 14, 2007 1:55 pm
by uberdragon
Hello,

I have a client that would like me to write a PHP application that will capture the terms that were searched for from the referrer (ie google) and then send that information to administration when they submit a contact form. Enabling them to automatically know which search term has resulted in the form submission.

I know log analyzers such as awstats etc is able to track what search terms brought traffic to the site. My question is:

How can I capture this information with PHP?

Any help is greatly appreciated!

Posted: Fri Sep 14, 2007 1:57 pm
by s.dot
If it's set, $_SERVER['HTTP_REFERER'] will contain the URI of the referring page.
php.net wrote:'HTTP_REFERER'

The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. 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.

Posted: Fri Sep 14, 2007 2:06 pm
by uberdragon
Ah.. just tested it...


Atleast with google the search parameters are in the string that will work.

Now to write a function to parse the url :)

Posted: Fri Sep 14, 2007 5:48 pm
by nickvd
uberdragon wrote:Ah.. just tested it...


Atleast with google the search parameters are in the string that will work.

Now to write a function to parse the url :)
A function similar to parse_url()? ;)