Forum Moderators: coopster

Message Too Old, No Replies

Getting a users search request using php

         

big_jimmi

11:42 am on Mar 20, 2007 (gmt 0)

10+ Year Member



Hi guys.

Im fairly new to php but am trying to find out if theres a way by using php that you can get a users search request that led them to your site ( so you can then write it along with the customers order to a mysql database)

ie if a person searched for blue widgets and then landed on your site- is there a way to capture this info along with the referer with php?

Ive already managed to get the referer - if its coming from a predetermined url such as www.bobswidgetlinks.com?referer=211 but would like to be able to do it accross the board.

many thanks in advance

eelixduppy

11:50 am on Mar 20, 2007 (gmt 0)



Hello,

We have a nice thread of PHP tricks in our library. One such trick is how to highlight searched terms [webmasterworld.com]. The method of retrieving the data is identical. You are going to be using the superglobal $_SERVER['HTTP_REFERER'] [us3.php.net] to get the data. Then once you get the data, you just insert it into the database. And remember to escape those variables :)

Good luck!

big_jimmi

12:28 pm on Mar 20, 2007 (gmt 0)

10+ Year Member



Thanks for the reply.

Would this work for people that search for our product on google for example?

Im really wanting to see exactly what people typed into a search engine to get to our site.

big_jimmi

5:42 pm on Mar 22, 2007 (gmt 0)

10+ Year Member



Can anyone else help? How do I capture the users referal string? I want to see and record in a mysql db where each sign up has come from?

any help would be gratfully received.

Thank you

jatar_k

6:25 pm on Mar 22, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



if you grab the referrer as eelix mentioned and then store it to a file or database that will work

if you want to track them through to some type of action to check conversions per term then you will have to use sessions or cookies to store it on the user side

big_jimmi

9:34 am on Mar 23, 2007 (gmt 0)

10+ Year Member



Thanks guys - I get you.