function ga_tokenizer_tokens in Google Analytics Tokenizer 7
Implements hook_tokens().
File
- ./
ga_tokenizer.module, line 10
Code
function ga_tokenizer_tokens($type, $tokens, array $data = array(), array $options = array()) {
$replacements = array();
$sanitize = !empty($options['sanitize']);
if ($type == 'ga_tokenizer') {
$ga_parse = new GA_Parse($_COOKIE);
foreach ($tokens as $name => $original) {
switch ($name) {
case 'ga-source':
$replacements[$original] = $sanitize ? check_plain($ga_parse->campaign_source) : $ga_parse->campaign_source;
break;
case 'ga-campaign':
$replacements[$original] = $sanitize ? check_plain($ga_parse->campaign_name) : $ga_parse->campaign_name;
break;
case 'ga-medium':
$replacements[$original] = $sanitize ? check_plain($ga_parse->campaign_medium) : $ga_parse->campaign_medium;
break;
case 'ga-content':
$replacements[$original] = $sanitize ? check_plain($ga_parse->campaign_content) : $ga_parse->campaign_content;
break;
case 'ga-term':
$replacements[$original] = $sanitize ? check_plain($ga_parse->campaign_term) : $ga_parse->campaign_term;
break;
case 'ga-first-visit':
$replacements[$original] = $sanitize ? check_plain($ga_parse->first_visit) : $ga_parse->first_visit;
break;
case 'ga-previous-visit':
$replacements[$original] = $sanitize ? check_plain($ga_parse->previous_visit) : $ga_parse->previous_visit;
break;
case 'ga-current-visit':
$replacements[$original] = $sanitize ? check_plain($ga_parse->current_visit_started) : $ga_parse->current_visit_started;
break;
case 'ga-times-visited':
$replacements[$original] = $sanitize ? check_plain($ga_parse->times_visited) : $ga_parse->times_visited;
break;
}
}
}
return $replacements;
}