TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   Search term loggin (http://www.talkphp.com/absolute-beginners/2232-search-term-loggin.html)

TlcAndres 02-12-2008 02:27 AM

Search term loggin
 
I imagine it's possible, logging the search term that was used to visit your site. Does anyone have any good examples.

Wildhoney 02-12-2008 02:32 AM

You would check the HTTP referrer and then extract the search term from the relevant GET parameter.

Wildhoney 02-12-2008 03:05 AM

Something like the following will do it for Google:

php Code:
if(isset($_SERVER['HTTP_REFERER']))
{
    if(preg_match('~&q=(?P<term>[^&]+)~i', $_SERVER['HTTP_REFERER'], $aMatches))
    {
        echo 'Search term: ' . urldecode($aMatches['term']);
    }
}

TlcAndres 02-12-2008 11:01 AM

Ah, ok thanks Wild.


All times are GMT. The time now is 06:07 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0