Jump to content

Need help to find what keywords got me traffic on google.


drew7721

Recommended Posts

Ok, first let me tell you what I want to do.  Google sends me traffic from many keywords, but I want to track what keyword does best for me as sales and so. The Analytics is good but I can't send the data to outside sites. So I figured this out : from the $_SERVER['HTTP_REFERER'] I can get the "q" value from the _GET and pass it on to track it... now I'm kind of stuck and I know it's easy but can't seem to find the function.

 

This is what I have so far:

/*
Code to try and store the keyword that was used to find and land on my site.
*/
$exurl = 'http://www.google.ca/url?sa=t&source=web&cd=1&ved=0CBYQFjAA&rct=j&q=mykeyword&ei=pJ2STMy8MsP-8AaqvuznBQ'; //set a demo refferer url that would usually be $exurl =  $_SERVER['HTTP_REFERER']
$refurl = parse_url($exurl, PHP_URL_QUERY); // remove all before and including the "?"
echo $refurl; // echo "sa=t&source=web&cd=1&ved=0CBYQFjAA&rct=j&q=mykeyword&ei=pJ2STMy8MsP-8AaqvuznBQ"

 

Ok, so I managed to get the important part out of the google URL, now how do I split this into an array that I can then use.

For instance  somefunction($refurl, $newarray); and then I could say    |  echo $newarray['q'];  | and it would echo "mykeyword"

Of course If there is a space in the keywords I should use the urldecode() function to avoid the % char...

 

Let me know if you know of any way to get this done.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.