Calling Mixpanel Alias and Identify events in WordPress

231 Views Asked by At

I am trying to call the Mixpanel alias and identify events into hooks for user_registration and wp_login but am getting undefined function errors on the alias function on registration and identify function on login.

I have included the Mixpanel javascript in my header and below are my two hooks that I am using in my functions.php file.

Any help on what I may be doing wrong here would be greatly appreciated!

// MIXPANEL REGISTRATION SCRIPT
function mixpanelRegistration($user_id) {
    mixpanel.alias($user_id);
}
add_action('user_register', 'mixpanelRegistration');


// MIXPANEL LOGIN SCRIPT
function mixpanelLogin($user) {
    mixpanel.identify($user->ID);
}
add_action('wp_login', 'mixpanelLogin');

1

There are 1 best solutions below

0
B. Jackson On BEST ANSWER

This issue was being caused by trying to call the mixpanel javascript library within my WordPress functions (PHP). Ended up needing to call in the mixpanel php library.