Developer Docs
  • API
    • 🔓Authentication
    • âš¡Events
  • Javascript SDK
    • 👾Get Session ID
Powered by GitBook
On this page
  1. Javascript SDK

Get Session ID

PreviousEvents

Last updated 3 years ago

The visitor ID will be automatically stored in the dataLayer under the attribute name w_session_id as soon as the SDK loads

How to retrieve the visitor ID:

setInterval(function() {
  var dataLayer = window.dataLayer;
  var isDefined = dataLayer && dataLayer.find(item => !!item.w_session_id);
  var visitorId = isDefined && isDefined.w_session_id;
}, 1000)

For more info on the dataLayer:

👾
https://developers.google.com/tag-platform/tag-manager/web/datalayer