Get referrer source URL from google search using php?

I am using $_SERVER['HTTP_REFERER']; to get the Referrer URL.

When I typed q='some text' in the Google search box

 `https://www.google.com.pk/#hl=en&output=search&sclient=psy-ab&q=some text%2Ftestbulkresponse&oq=some text%2Ftestbulkresponse&gs_l=hp.3...15460.24280.1.25007.30.30.0.0.0.0.325.7136.2-27j3.30.0...0.0...1c.1.8.hp.dAvuch3bBg4&psj=1&bav=on.2,or.r_qf.&bvm=bv.44697112,d.ZWU&fp=980e418276b62e8c&biw=1366&bih=595` 

but when I get this URL on my website using $_SERVER['HTTP_REFERER'];

the q=null like this

 `http://www.google.com.pk/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&ved=0CC0QFjAA&url=http%3A%2F%2Fwww.bulkresponse.com%2Ftestbulkresponse%2Fdashboard.php&ei=r9NbUfv7GcjaOYDdgKgC&usg=AFQjCNF9U_DpJEwupZ0ZLPbjWJ6DQLWZcA&bvm=bv.44697112,d.ZWU`. 

So, I canโ€™t find the keywords on Google, what should I do to find the keywords I need?

+6
source share
3 answers

Google removes the search query for HTTPS connections and registered users, so the only way to find out the search query is to use Google Analytics

When you search from https://www.google.com , the websites you visit from our organic search ads will still know that you came from Google, but will not receive information about each individual request.

http://googleblog.blogspot.com.es/2011/10/making-search-more-secure.html http://analytics.blogspot.com.es/2011/10/making-search-more-secure-accessing .html

+17
source

Try it.

 parse_str(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY), $queries); echo $queries['q']; 

Literature:

http://php.net/parse_url

http://php.net/parse_str

+1
source
 $ref = $_SERVER['HTTP_REFERER']; if(strstr($ref, "google.com")){ //echo $ref; $regex ='/q=(.+?)&/'; preg_match($regex, $ref, $query); echo $query[1]; } 

it does not work every time, especially now with their updates. I get the message & esrc = s.

+1
source

All Articles