As businesses collect more and more GA4 data, the structure in which that data is rendered becomes increasingly important.
As businesses collect more and more Google Analytics 4 (GA4) data, the structure in which that data is rendered for collection from the user-facing front-end platform becomes increasingly important. Two common approaches to organising data on the front-end are a structured / nested data layer and a flat data layer. Each approach has its own advantages and disadvantages.
There are a few definitions depending on the context you're discussing the data layer in (e.g. when discussing it in conversations about team structure and resourcing, a data layer is a mechanism for dividing roles, responsibilities and resource), but the definition that applies to the context of this article is:
The data layer is implemented by developers but designed and managed by data architects or data engineers, who ensure that the data is properly structured and formatted.
As implied, it acts as a 'layer' between data sources and applications such as websites or apps, allowing for efficient data collection and use.
Tag Managers such as Google Tag Manager (GTM) which is frequently used with GA4, will typically read from a data layer before enrichment and sending off to various 3rd party analytics and MarTech tags.
Critical for large complex platform, a data layer enables scalability, efficient data collection, data standardisation, data security & compliance, and can help businesses make better decisions, improve efficiency (both development and data collection), and deliver better customer experiences.
A structured nested data layer is where data is organised into a hierarchical structure with use of arrays. This structure can be thought of as a tree, with each node representing a level of the hierarchy. The nodes are connected to one another in a way that represents the relationships between the data they contain.
Note, for a Product Listing Page called 'Kitchen Products', the data layer has 2 sections, one for the page related data, and a second for the product items on display, in this case there are 2 products.
A flat data layer is where the data is organised into a single level with each row representing a single field of data. The data is stored in a way that allows for easy retrieval of individual records.
For the same page as before, the keys are all at the same level, however, this time the multiple products are listed as arrays in the same key. So now you need to use an 'index' in GTM to read the position of a specific product in the product name and matching product id arrays, or just loop through to read all the products displayed.
Both a structured nested data layer and a flat data layer have their own unique strengths and weaknesses. A structured nested data layer is highly organised and scalable, but can be complex to set up and maintain. A flat data layer is simple and easy to use, but lacks the organisational structure and scalability of a structured nested data layer.
Ultimately, the decision of which approach to use will depend on the specific needs of a business and the types of data it needs to store and manage.
If your business needs to transform your GTM data layer for GA4 as it has outgrown its purpose get in touch with us at Loop Horizon!
Looking for more articles like this? Follow us on LinkedIn so you never miss a post.