track my WordPress user logins?
function hook_javascript() {
?>
<script type="text/javascript" src="//script.leadboxer.com/?dataset=YOUR DATASETID HERE"></script>
<?php
};
function hook_identification() {
$user_info = wp_get_current_user();
$user_email = $user_info->user_email;
$user_firstname = $user_info->user_firstname;
$user_lastname = $user_info->user_lastname;
?>
<script type="text/javascript">
// define an empty variable called 'map'
var map = new OTMap();
//define one or multiple properties to be added to the visitor profile
map.put("firstName", "<?php echo $user_firstname; ?>");
map.put("lastName", "<?php echo $user_lastname; ?>");
map.put("email", "<?php echo $user_email; ?>");
//send (submit) the data to LeadBoxer
OTLogService.sendEvent("Login added", map, false);
</script>
<?php
}
function lb_function()
{
if ( is_user_logged_in() )
{
add_action('wp_head', 'hook_identification');
}
}
add_action('wp_head', 'hook_javascript');
add_action('init', 'lb_function');<br>Notes:
Last updated
Was this helpful?
