Understanding sessions
The term session is often used in different ways to describe concepts related to browsers and the Internet. Digital Web has a specific definition of sessions that impacts the application. For example, parts of the targeting process are based on session information, such as only presenting a survey once in a session. This functionality relies on storing the information in the browser's localStorage.
In the simplest terms, a session as defined by Digital is started when a client, such as a web browser, opens a page on a domain where Digital is embedded. Session time is reset if the domain changes or is different from the referring domain, or if there is a direct navigation such as document.referrer = null. There is no time constraint on session length. The information about the session is stored as key-value pairs in the browser's localStorage, meaning that it is shared across all tabs and windows from the same client, and it persists over browser restarts. This impacts keys such as KampylePageLoadedTimestamp, where every page load for the client this key is updated. Because the keys are in the browser's localStorage, whenever any tab is loaded, keys such as KampylePageLoadedTimestamp are updated.
The following criteria determine when a new Digital Web session is started. They are evaluated using an OR logic. In other words, if any of these criteria are met, then a new session is started:
- The
kampyleUserSessionkey does not exist. - There was a direct navigation to the page. Specifically, the
document.referrerorwindow.parent.document.referreris blank. - The HTTP referrer is different than the current host. Specifically, if the domain in
document.referrerandwindow.location.hostdo not match.
When one of the criteria are satisfied a new Digital session is started, and the following occurs:
- The
kampyleUserSessionkey is updated with the current timestamp. - The
kampyleSessionPageCounterkey is incremented by 1. - The
kampyleUserPercentilekey is deleted. - The
kampyleInvitePresentedkey is deleted. - The
md_isSurveySubmittedInSessionkey is deleted
For more information on stored keys, see Locally stored data.
Frequently asked questions
These questions assume the visitor opened a new browser tab to www.example.com and they have been there before.
What happens when they refresh the browser page?
This is effectively a new session. Why? Because the same state exists. The kampyleUserSession key exists, but the next test is direct navigation. The document.referrer will be blank, therefore it is a new session.
What happens when they hard-refresh the browser page?
This is also a new session for the same reasons as the previous answer.
What happens when they use Empty-Cache and Hard reload?
This is also a new session for the same reasons as the first answer. The Empty-cache does not delete keys or localStorage.
What happens when they navigate through pages without Digital embedded?
Often a web site redirects visitors through a page where the Digital embed code is not deployed, for example during authorization of a user. In this situation, the session counter is not changed.
