Identity Feature for Web

Overview

Sourcepoint has implemented the identity feature to manage the consent preferences using authID. This section explains the behavior of a site and app with and without the Identity Feature as well its implementation.

Without identity feature

When a user accesses a site through a mobile or a desktop a consent view is displayed. The user selects the consent preferences on the consent view. These consent preferences are stored in Sourcepoint Endpoints.

If the same user accesses the same site through another mobile or desktop, the user is considered as different or a new user. The user has to again select their consent preferences from the consent view.

With identity feature

When a user accesses a site through a mobile or a desktop a consent view is displayed and a unique authID is also generated. The user selects the consent preferences on the consent view. These consent preferences are stored in the Sourcepoint Endpoints along with the authID.

If the same user accesses the same property through another channel or device: mobile or desktop, the user is identified based on the authID and is considered as the same user. The user consent preferences will carry over that session. The user is also able to update their consent preferences from the consent view.

Implement identity feature

With the identity feature, you have to generate a unique authID such as email or mobile number. While initializing SDK you must pass this authID along with account ID, site name, and others. This authID is saved on Sourcepoint Endpoint along with the consent preferences.

Function to set the authId

This section provides the function to set the authId.

Sourcepoint asks a publisher to set a first-party cookie called authId. The first-party cookie is set with the authneticated ID of the user that is sent from the publisher's authenitcation system.

The function is set in the following way with authID.

setSession(authResult, pathName) {
// Set isLoggedIn flag in localStorage
localStorage.setItem('isLoggedIn', 'true');
// Set the time that the access token will expire at
let expiresAt = (authResult.expiresIn * 1000) + new Date().getTime();
this.accessToken = authResult.accessToken;
this.idToken = authResult.idToken;
const userId = this.getUserIdFromToken(this.idToken);
// Reviel id to the page
document.cookie = `authId=${ userId }`;
this.expiresAt = expiresAt;
history.replace(pathName);
}