Tracking Users

Must Read

We recommend that you get acquainted with all the concepts related to Customers and Events before proceeding. Doing so will help you understand the workings of this section, better.

Identifying Users

At Antsomi, user tracking begins immediately upon the integration of our SDKs into your platform. As users visit your website, the Antsomi SDK seamlessly assigns a unique ID, known as a UID (User ID), creating an anonymous profile in our backend system. This profile is a repository for all behavioral data and session information, including System Events, Custom Events, System User Attributes, and Custom User Attributes.

To establish a more concrete connection between a user and a customer, you have the option to assign a CID (Customer ID) at pivotal moments in the user's journey:

  • Upon user signup.

  • During user login.

  • When the user's identity becomes known, such as specific page views or interactions.

Assigning a CID holds several crucial implications:

  • Marks the user as identified and recognized as a "Customer" in your CDP365 dashboard.

  • Initiates the creation of a new "Customer Profile" containing all user data, even if no prior profiles exist for that CID in CDP365.

  • Merges all previous anonymous profiles associated with the user into this new "Customer Profile," providing a unified view of the user's interactions across your platform.

How Customer Profiles are Merged When User is Identified (assigned a CID)

Let's illustrate this process with an example:

Assume User A visits your website multiple times before signing up:

Day 1: User A opens your website, Antsomi assigns them a UID, creating Anonymous Profile 1.

Day 3: User A revisits, gets a new UID, and creates Anonymous Profile 2.

Day 7: User A returns, creates an account, and assigns a CID. This action leads to the creation of a new user profile.

  • Antsomi conducts a backend check to identify anonymous user profiles created during the user's prior visits as soon as the Customer Profile is created.

  • In this case, Anonymous Profile 1 and Anonymous Profile 2 merge into the final profile of User A, offering a consolidated view of their preferences and behavioral history.

Guidelines

When assigning a Customer ID (CID) to identify your users, consider the following:

  • A customer ID cannot be changed once assigned.

  • For enhanced security and uniqueness, it is advisable to use hashing methods (e.g., MD5 or SHA256) with user-specific information like email addresses or phone numbers.

On Login

To allocate a customer identification (CID), use the following code snippet. Any attributes, events, or session data collected before using this API are initially linked to an automatically generated anonymous user. Upon calling this custom implementation, all previously stored information becomes associated with the identified customer.

web_event.track("user", "sign_in", {
    dims: {
        customers: {
            customer_id: window._cdpEventFunction.md5(email),
            name: customerName,
            email: email
        }
    },
    extra: {
        identify_id: window._cdpEventFunction.md5(email),
        identify_time: window._cdpEventFunction._cdpGetLeadTime(),
        identify_event: "user_sign_in",
        identify_type: "exact"
    }
});

On Identified

In scenarios where users might not explicitly log in during each session but maintain an active login session, it's crucial to identify them at strategic intervals to ensure accurate customer information capture. The identify_user event serves this purpose and is typically called once per day to update customer data.

web_event.track("user", "identify", {
    dims: {
        customers: {
            customer_id: window._cdpEventFunction.md5(email),
            name: customerName,
            email: email
        }
    },
    extra: {
        identify_id: window._cdpEventFunction.md5(email),
        identify_time: window._cdpEventFunction._cdpGetLeadTime(),
        identify_event: "user_identify",
        identify_type: "exact"
    }
});

On Logout

Ensure you call web_event.resetAnonymousUId() when the logged-in customer logs out or when you do not want to attach any future event, session, or user data with this customer until the user signs in again.

btnLogout.addEventListener("click", function () {
    web_event.resetAnonymousUId();
});

Customer Attributes

Antsomi allows you to associate additional details such as name, email address, location, and more with your customer profiles. For example, in the sign-in event code snippet above, you can send more attributes beside customer_id and name, like the code snippet below

web_event.track("user", "sign_in", {
    dims: {
        customers: {
            customer_id: window._cdpEventFunction.md5(email),
            name: customerName,
            email: email,
            phone: phone,
            gender: gender,
            date_of_birth: dob
        }
    },
    extra: {
        identify_id: window._cdpEventFunction.md5(email),
        identify_time: window._cdpEventFunction._cdpGetLeadTime(),
        identify_event: "user_sign_in",
        identify_type: "exact"
    }
});

Last updated