Extending the session length
Session lifecycle
Section titled Session lifecycleGeneral rule
Section titled General ruleThe session lifecycle is handled by the Tracking Tag on the browser side. The session ends 30 minutes after the last user event.
Session initialization
Section titled Session initializationTo manage the session, the Tag creates a session cookie called _cs_s
which has its expiration date set to 30 minutes after its initialization. When the tag is executed, it checks for the _cs_s
cookie:
- If the cookie does not exist, it will increment the session number (stored in the
_cs_id
cookie) and will create the session cookie_cs_s
- If the cookie already exists, it will only update the expiration date (now +30 minutes).
Session update
Section titled Session updateWhen a pageview event is triggered, natural or artificial, the _cs_s
cookie expiration date is updated (+30 minutes).
Extending the session
Section titled Extending the sessionTo artificially extend the session duration, use the extendSession
command:
When this command is called the Tag starts a process which:
- Updates the expiration date of the session cookie
_cs_s
to 30 minutes after the process is run - Sends a dynamic variable with the key
session_expiry_update
and the process iteration number as value so that the Contentsquare data pipeline knows that the session should not be closed (example{session_expiry_update: 2}
).
This process will run every 29 minutes:
- As long as the session length has not reached 4 hours (maximum duration of a session), counting from the beginning of the session, not the moment the command executed.
- Until a new pageview event is triggered (natural or artificial). The process is then stopped and the session management goes back to its normal behavior.
Thanks to this process, the command only has to be called once per pageview.
Clear previous visitors data
Section titled Clear previous visitors dataUse the session:clear:visitor
command to clear all data linked to previous visitors:
- Cvars
- Consent
- Exclusion
- Visitor ID
- Page number
- Session number
The command must be pushed before the Tag starts:
Create a new visitor
Section titled Create a new visitorUse the session:start:newVisitor
command to trigger the creation of a new visitor.
The session:start:newVisitor
command: