Identification of unique visitor

 

Foreword

Before starting implementation of the ClientSideUserId plugin, please make sure you have initialised the AT Internet JavaScript Tracker and selected the plugin from within the Tag Composer interface.

 

Principle

The ClientSideUserId plugin enables a visitor to be tracked by creating a user ID in cases where writing a third-party cookie is not feasible. For example, this might be the case on an Intranet site, or when the Safari browser is used (default settings), or when a visitor browses using an Apple device like iPhone, iPad or iPod. It is also possible to configure the plugin to force the use of a random or custom ID. This ID can be found in the idclient variable, present in all hits when the plugin is active.

 

Plugin setup

The plugin’s mode of function can be directly configured from within the interface, or via the settings when the Tracker is initialised.

Three modes are available:

  • required: The user ID is added to all hits on the Safari browser, or in cases where an Apple device is used.
  • always (by default): The user ID is added to all hits, on any type of device.
  • never: The plugin is disabled, the user ID is never added to hits.

To change the mode, please add the following code where desired:

Add user ID to all hits, only for affected devices (Safari, iPhone, iPad, iPod):

var config = {ClientSideUserId: {clientSideMode: 'required'}};
var tag = new ATInternet.Tracker.Tag(config);

Add user ID to all hits:

var config = {ClientSideUserId: {clientSideMode: 'always'}};
var tag = new ATInternet.Tracker.Tag(config);

Never add user ID:

var config = {ClientSideUserId: {clientSideMode: 'never'}};
var tag = new ATInternet.Tracker.Tag(config);
 

Managing user ID

The user ID must be filled in during the user’s entire visit (on all hits). This ID is stored in a cookie on the domain indicated in the Tracker settings (cookieDomain variable), in order to be re-used on pages where it is not filled in.

If needed, the cookie containing the user ID can be configured directly via the settings:

Define cookie lifetime (in days, 397 by default):

var config = {ClientSideUserId: {userIdCookieDuration: 397}};
var tag = new ATInternet.Tracker.Tag(config);

Define a set/fixed lifetime for the cookie (by default):

var config = {ClientSideUserId: {userIdExpirationMode: 'fixed'}};
var tag = new ATInternet.Tracker.Tag(config);

Set up a sliding/relative cookie:

var config = {ClientSideUserId: {userIdExpirationMode: 'relative'}};
var tag = new ATInternet.Tracker.Tag(config);
 

Declaring user ID

If an ID is not found in the tag, nor in the cookie, a unique ID is generated.

You may force a user ID:

By passing a userIdentifier context variable:

var config = {
    ClientSideUserId: {
        clientSideMode: 'required',
        userIdCookieDuration: 397,
        userIdExpirationMode: 'fixed'
    }
};
var context = {
    userIdentifier: 'userID'
};
var tag = new ATInternet.Tracker.Tag(config, context);

By using the plugin’s set function:

var config = {
    ClientSideUserId: {
        clientSideMode: 'required',
        userIdCookieDuration: 397,
        userIdExpirationMode: 'fixed'
    }
};
var tag = new ATInternet.Tracker.Tag(config);
tag.clientSideUserId.set('userID');

In cases where both methods are used, the set function retains priority.

Last update: 12/10/2021