Native Browser Storage, Data Layer Examples

The Native Browser Storage Listener automatically generates data layer activity when browser storage values are set or changed on your website. Learn about the specific data layer activity generated with the examples below.

Using the Data Layer With Browser Storage Values

Learn more about how ListenLayer generates powerful data layers from the activity on your website, specifically from Native Browser Storage.

Custom Data Layer Events

Configure ListenLayer to focus on specific browser storage activity on your website, regardless of what application or script sets or changes that browser storage.

Whenever your browser storage activity occurs, ListenLayer pushes an event into the data layer called ‘nativeBrowserStorage’ along with specific details about the browser storage activity.

event: 'nativeBrowserStorage'

Automatic Data Layer Values

When the ‘nativeBrowserStorage’ event is pushed into the data layer, the Listener will include variables containing all the information about the browser storage event, including

  • The value stored inside the browser storage key, in its original form
  • The value stored inside the browser storage key parsed out so you can access individual elements easily
  • The timestamp of the activity, displayed is various formats and timezones
  • The location on your website or application where the browser storage activity occurred

A complete code example is shown to the right, including a full set of available timezone data.

  event: "nativeCookie",
  nativeName: "ScreenOne_lastForecastWeather",
  nativebrowserstorage: {
    ScreenOne_lastForecastWeatherContents: {
      fullValue: "{\"latitude\":\"39.4895\",\"longitude\":\"-104.8447\"}",
      parsedValue: {latitude: 39.4895, longitude: -104.8447}
    }
  },
  nativebrowserstorageCustomValues: {},
  nativebrowserstorageLocation: {
    url: "https://demo.hostedstaging.com/native/",
    tld: "hostedstaging.com",
    hostname: "demo.hostedstaging.com",
    pathname: "/native/",
    queryString: null,
    fragment: null,
    protocol: "https",
    originPathName: "https://demo.hostedstaging.com/native/"
  },
  eventTimestamp: {
    userTime: {
      timezone: {
        fullTimezone: "UTC-07:00(America/Denver)",
        timezoneName: "America/Denver",
        utcOffsetHours: -7,
        utcOffsetSeconds: -25200,
        observingDST: 0
      },
      time: {
        epoch: 1642955039,
        iso8601: "2022-01-23T09:23:59.514Z",
        fullTimestamp: "Sun Jan 23 2022 09:23:59 UTC-0700 (America/Denver)",
        date: "2022-01-23",
        dateString: "Jan 23 2022",
        dayOfWeek: "Sun",
        timeOfDay: "09:23:59"
      }
    },
    utcTime: {
      time: {
        epoch: 1642980239,
        iso8601: "2022-01-23T16:23:59.514Z",
        fullTimestamp: "Sun Jan 23 2022 16:23:59 UTC",
        date: "2022-01-23",
        dateString: "Jan 23 2022",
        dayOfWeek: "Sun",
        timeOfDay: "16:23:59"
      }
    },
    listenlayerAccountTime: {
      timezone: {
        fullTimezone: "UTC-07:00(America/Denver)",
        timezoneName: "America/Denver",
        utcOffsetHours: -7,
        utcOffsetSeconds: -25200
      },
      time: {
        epoch: 1642955039,
        iso8601: "2022-01-23T09:23:59.000Z",
        fullTimestamp: "Sun Jan 23 2022 09:23:59 UTC-0700 (America/Denver)",
        date: "2022-01-23",
        dateString: "Jan 23 2022",
        dayOfWeek: "Sun",
        timeOfDay: "09:23:59"
      }
    }
  }

Custom Data Layer Values

ListenLayer allows you to write rules that push custom values into the data layer events from your browser storage activity. Use this to segment & enrich your analytics & measurement strategies or to modify triggers inside of Google Tag Manager using simple conditions.

 nativebrowserstorageCustomValues: {
//write rules to push custom data layer values here
}