---
title: "Discussion on \"What Is the Data Layer and Why Do You Need It?\" | Hashnode"
description: "Discussion on \"What Is the Data Layer and Why Do You Need It?\". Understanding the layered architecture of websites and apps"
url: "https://hashnode.com/posts/what-is-the-data-layer-and-why-do-you-need-it/6382a622a13dac5220d29d4d"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [What Is the Data Layer and Why Do You Need It?](https://analyticsinstitute.hashnode.dev/what-is-the-data-layer-and-why-do-you-need-it?utm_source=hashnode&utm_medium=feed)

Understanding the layered architecture of websites and apps

Nov 26, 2022 · 3 min read · analyticsinstitute.hashnode.dev  
Read the article

-   [#ecommerce](https://hashnode.com/tag/ecommerce)
-   [#data](https://hashnode.com/tag/data)
-   [#architecture](https://hashnode.com/tag/architecture)
-   [#javascript](https://hashnode.com/tag/javascript)
-   [#analytics](https://hashnode.com/tag/analytics)

## Written by

[Analytics Institute](https://hashnode.com/@analyticsinstitute)

@analyticsinstitute · USA

  
[View profile](https://hashnode.com/@analyticsinstitute)

I write about digital analytics and web development.

I write about digital analytics and web development.

## Responses 1

Markdown supported · ⌘↵ to post

[Matthew Stead](https://hashnode.com/@matievisthekat)

[Nov 27, 2022](https://hashnode.com/posts/what-is-the-data-layer-and-why-do-you-need-it/6382a622a13dac5220d29d4d/comment/63832936bdbd2c06dff640a2)

Does the dataLayer persist between page redirects/page refreshes or do you need to add properties to it every time the page loads?

[Analytics Institute](https://hashnode.com/@analyticsinstitute)

[Dec 4, 2022](https://hashnode.com/posts/what-is-the-data-layer-and-why-do-you-need-it/6382a622a13dac5220d29d4d/comment/63832936bdbd2c06dff640a2#reply-638c3cda64b7288d8d8e515b)

Hi [Matthew Stead](https://hashnode.com/@matievisthekat), it doesn't persist by default. You can test this by pushing something to the data layer on your browser console, refreshing, then checking to see if what you pushed is still in the data layer.

Enter the following in the console:

window.dataLayer = window.dataLayer || \[\]; dataLayer.push({'event': 'happiness'});

You can then type "dataLayer" to see if the new event is there (it is). Refresh the page and type "dataLayer" again, and it will be gone.

However, you can configure the data to persist through cookies, local storage, or session storage.
