Forum Moderators: DixonJones
For php you could use this:
function get_vars($string)
{
$ret = array();
$v2 = split("[?&]",$string);
foreach($v2 as $x1){
$x = explode("=",$x1);
$ret[$x[0]] = $x[1];
}
return $ret;
}
function get_var($var_name,$string)
{
$a = get_vars($string);
return $a[$var_name];
}
$referrer = $_SERVER['HTTP_REFERER'];
$prev = get_var('prev',$referrer);
$prev = urldecode($prev);
$q = get_var('q',$prev);
$var = str_replace("+"," ",$q);
echo "image search keywords:".$var."<br />"; But the solution you are looking for to track image search with google analytics can be very easily found on the web by using your favourite search engine.
References:
[code.google.com...] (see "Search Engine Configuration" section)
[joostdevalk.nl...]
Also note, the referer strings from Google Images can be extremely long - so some tracking software truncates the referer url, which drops the keywords so they're not available. If this is the case for anyone, they need to modify the analytics package they are using or get the supplier to do that.