Skip to Content
AI Powered Docs! 🤖 These docs are translated with AI, so keep an eye out for minor quirks. We're always improving!

Identifying Users to Metrix and Creating a User (Specific to Automation Service)

To identify a user who is using your website to Metrix servers so that Metrix can attribute received actions to the relevant user, you must first execute the following method before calling any other methods. This method creates a User on Metrix servers, which can be accessed through the Metrix user panel in the User Lookup section.

Metrix_SDK::authorize_user($customUserId);
NameTypeDescriptionRequired
customUserIdstringA unique identifier you have assigned to the user on your website, such as a username or any other unique ID.Yes

For example:

<?php $current_user = wp_get_current_user(); if ($current_user->ID) { Metrix_SDK::authorize_user($current_user->user_login); } ?>

This action will create a User on the Metrix servers, which can be viewed in the User Lookup section of the panel.

Method to log out and return the user to an anonymous state:

Metrix_SDK::deauthorize_user($customUserId);

Update User Information (Specific to Automation Service)

After identifying the user authorize_user, you can update their information in User Lookup using the following methods:

set_first_name($first_name)
set_last_name($last_name)
set_email($email)
set_hashed_email($hashedEmail)
set_phone_number($phone_number)
set_hashed_phone_number($hashed_phone_number)
set_country($country)
set_city($city)
set_region($region)
set_locality($locality)
set_gender($gender)
set_birthday($birthday)
set_custom_attribute($key, $value)
set_custom_user_id($id)

Implementation Example:

<?php $current_user = wp_get_current_user(); if ($current_user->ID) { // Identify the user Metrix_SDK::authorize_user($current_user->user_login); // Update user information Metrix_SDK::set_first_name($current_user->user_firstname); Metrix_SDK::set_last_name($current_user->user_lastname); Metrix_SDK::set_email($current_user->user_email); Metrix_SDK::set_country('Iran'); Metrix_SDK::set_city('Tehran'); Metrix_SDK::set_custom_attribute('membership_level', 'VIP'); } ?>

This code ensures all user information is recorded and traceable in Metrix’ User Lookup.