homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / WebmasterWorld / Website Analytics - Tracking and Logging
Forum Library, Charter, Moderators: Receptional & mademetop

Website Analytics - Tracking and Logging Forum

Capturing Keywords on Form

 8:43 pm on May 25, 2010 (gmt 0)

I got a question I have some landing pages that I work with and I have the forms on the page send me an email with the information collected. Is there a way to add the keyword or even search query that the user came in on to the email that is sent to me?



 7:58 am on May 26, 2010 (gmt 0)

I'm not sure if this is technically possible.
Your data come actually from OUTsource. Some statistical code connected to your page could perform this. But as I understand google does not support this.


 3:51 pm on May 26, 2010 (gmt 0)


It's apparently not foolproof though.


 9:34 pm on May 27, 2010 (gmt 0)

Unfortunately you won't get a referer if the search comes from the experimental google AJAX search or from the new https search.
This is a problem that I will have to deal with in my WP TID Generator product [wptidgenerator.com], too.

binarymonkey suggested the following code on the google forum [google.com] to deal with that problem:

* Returns an array with details held in Google Analytics cookie,
* or false if cookie not set.
* @returns array|bool
function google_analytics_cookie_data() {

if(isset($_COOKIE['__utmz'])) {

preg_match_all('$[a-z]*=[^\|]*$', $string, $matches);

$ga_data = array();
foreach($matches[0] as $kvpair) {

$bits = explode('=',$kvpair,2);

$key = $bits[0];
$val = $bits[1];

switch($key) {

case 'utmcsr':
$key = "Source";

case 'utmccn':
$key = "Campaign";

case 'utmcmd':
$key = "Medium";

case 'utmcct':
$key = "Referring Page";

case 'utmctr':
$key = "Keywords";


$ga_data[$key] = $val;


return $ga_data;

} else {
return false;


It extracts the keywords from the google analytics cookie, which of course means that you have to run google analytics in order to be able to use it.


Global Options:
 top home search open messages active posts  

Home / Forums Index / WebmasterWorld / Website Analytics - Tracking and Logging
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved