Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to capture search term from Google search?

This may be a stupid question, but is it possible to capture what a user typed into a Google search box, so that this can then be used to generate a dynamic page on the landing page on my Web site?

For example, let's say someone searches Google for "hot dog", and my site comes up as one of the search result links. If the user clicks the link that directs them to my Web site, is it possible for me to somehow know or capture the "hot dog" text from the Google search box, so that I can call a script that searches my local database for content related to hot dogs, and then display that? It seems totally impossible to me, but I don't really know. Thanks.

like image 423
johnnyb10 Avatar asked Jun 02 '09 19:06

johnnyb10


People also ask

Can I get search data from Google?

To access the report, log into Search Console, and then click “Search Traffic” in the left-hand navigation. Search Analytics is the first report listed within this menu option. If you're not able to access Search Console, it may be because you have to verify your website first.

How do I find Google search terms?

Just type in the Google search box, and related terms will display in a drop-down list. You can then manually select the long-tail keyword phrase you want to use or pick a combination of phrases.

Can Google Analytics track search terms?

The Google Analytics Site Search reports allow you to see the search terms people use, the pages where they start their search, and the pages they navigate to from your search results page. These reports can provide insights into your content, navigation, and even your search campaigns.


1 Answers

I'd do it like this

$referringPage = parse_url( $_SERVER['HTTP_REFERER'] );
if ( stristr( $referringPage['host'], 'google.' ) )
{
  parse_str( $referringPage['query'], $queryVars );
  echo $queryVars['q']; // This is the search term used
}
like image 63
Peter Bailey Avatar answered Oct 20 '22 08:10

Peter Bailey