Retrieving Contentsquare session identifiers from the customer's website

Once an integration has been installed, the Provider should start collecting Contentsquare session identifiers during web visits on the common customer’s website. These identifiers will be used to attach the enrichment data to the right Contentsquare sessions when data will be received from the Provider.

Those identifiers are:

  • The project ID: identifies the Contentsquare project ID where the data is stored
  • The user ID: identifies the Contentsquare anonymous user ID for the user visiting the website
  • The session number: identifies a specific session (as an ordered index) of the user ID (e.g. if Contentsquare has tracked 4 different sessions of the same anonymous user, the last session number will be 4)

How to get those Contentsquare session identifiers?

Section titled How to get those Contentsquare session identifiers?

During a visit on a website, you can interact with Contentsquare’s tag to pull those identifiers via the afterPageView command. A JavaScript code using that command should look like this:

const yourCallback = (context) => {
const projectId = context.projectId;
const [userId, sessionNumber] = context.sessionKey.split(".");
// store these Contentsquare session identifiers in your backend
};
window._uxa = window._uxa || [];
_uxa.push(["afterPageView", yourCallback]);

By calling this function you will get the project ID, user ID and session number of each session that are required to identify the Contentsquare sessions to be enriched.