drew7721 Posted September 16, 2010 Share Posted September 16, 2010 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 https://forums.phpfreaks.com/topic/213615-need-help-to-find-what-keywords-got-me-traffic-on-google/ Share on other sites More sharing options...
drew7721 Posted September 17, 2010 Author Share Posted September 17, 2010 GOT IT ! <?php $refurl = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY); parse_str($refurl, $info); echo $info['q']; ?> Link to comment https://forums.phpfreaks.com/topic/213615-need-help-to-find-what-keywords-got-me-traffic-on-google/#findComment-1111897 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.