Identifying customers

Automatic identification

Exponea automatically creates an anonymous customer when the method initialize() is called for the first time on a device. These customers are identified by a generated cookie which means that subsequent sessions within a single device will be tracked to the same customer.

Multi-device identification

Apart from the automatic cookie tracking, Exponea also allows clients to track a single customer across more platforms or devices. Therefore we can for example connect events that customers make in the Android and iOS version of your business.

Explanation

We will use the method identify(hard_id) to assign a hard ID (e.g. email adress or username) to the current user. When a customer with the given hard ID already exists, all customer profiles with the same ID will be merged. Therefore we need to be sure, that the we are identifying the customer correctly. After identification, we will see that the registered identity field of the user has been updated in Exponea. When a customer is identified with a different hard ID, a new customer is created, however, all previous events remain in the previous customer history.

Implementation

We can use the identify() method in two ways:

  • identify(hard_id);
    • identity field registered will be updated
  • identify({identity: id});
    • We can save various hard IDs for a customer. However, customers are merged under every hard ID. Therefore if two customers with different registered are identified with same hard ID identity field, event tracking will fail. If your project needs a custom identity field, please contact Exponea.

A good practice is to identify customer after every successful login/registration. More frequent identification may lead to problems with customer merging. Also, make sure, that the hard ID is the same as always (e.g. they are case sensitive).

Sample implementation

if(document.location.href.indexOf('/login/success/') > -1){
  var email = validateEmail(data.getEmail());
  if(email){
    exponea.identify(email);
  }
}