[Plugin: Google Analytics for WordPress] How can I add my own custom variable
-
How can I add my own custom variable? I want to track who logged in $current_user. I added this code to functions.php and it shows up in the <head> but below the yoast script?
function jt_gatrackuser() {
global $current_user;
get_currentuserinfo();
echo “\n”;
echo ‘<script type=”text/javascript”>’ . “\n”;
echo ‘//![CDATA[‘ . “\n”;
echo ‘var _gaq=_gaq || [];’;
echo ‘_gaq.push([\’_setCustomVar\’,4,\’username\’,\”;
echo $current_user->user_login;
echo ‘\’,2]);’ . “\n”;
echo ‘//]]’ . “\n” . ‘</script>’;
echo “\n”;
}
add_action(‘wp_head’, ‘jt_gatrackuser’);?>
This is what get generated below the Yoast script
<script type=”text/javascript”>
//![CDATA[
var _gaq=_gaq || [];_gaq.push([‘_setCustomVar’,4,’username’,’Jim’,2]);
//]]
</script>http://wordpress.org/extend/plugins/google-analytics-for-wordpress/
- The topic ‘[Plugin: Google Analytics for WordPress] How can I add my own custom variable’ is closed to new replies.