The Data Layer is a powerful feature, providing you with fine-grained control over the data sent to various analytics. This guide will walk
you through the essentials of crafting a Data Layer to enhance your data collection strategy.
A Data Layer is a structured data format used to define and send detailed information about user interactions,
page characteristics, and more, directly within your HTML page. By including a Data Layer, you can instruct Edgee on exactly what data
to collect, how to process it, and where to send it.
The way you insert a Data Layer in your application depends on the Edgee SDK you’re using.
For HTML applications you can manually insert the Data Layer within a <script> tag with type="application/json" and a specific ID.For React applications, you can use the EdgeeDataLayer component from the react-edgee package.
Please note that the typical Data Layer object is very small and only includes one or two events.
You can find a few examples of valid objects at the end of this page.The following code represents the full schema of everything you can define in your Data Layer:
General info about this page that can be used across events.
user
optional
Object
General info about the user that can be used across events.
Note: when you define context data about the current page or user, it’s going to be used automatically
for all compatible events, so you don’t need to provide the same information multiple times.
For example, data_collection.context.user is used to define the data fields for user events.
Even if you don’t define this field, it will be set to true by default. But if you set it to false, no component will receive the data.
<component_name>
optional
Boolean
If true, the specified component will receive the data. If false, the component will not receive the data.
Use the components object to specify which analytics components should and should not receive the data. If you do not specify any component,
all configured components will receive the data by default.You can find a few examples in the next section.
Remember: the components object can be set globally for all data collection or for individual events.
This gives you full control and the ability to be very granular about what data is sent to which components.
Please also note that the components object defined for an individual event will
override the global configuration for that event.
Precision and Clarity: Ensure that each field in the data layer is accurately defined. Clear, descriptive values for page names, categories, and properties enhance data quality.
Consent and Privacy: When including any personally identifiable information (PII) in the identify section, ensure you have obtained explicit consent from the user in compliance with GDPR, CCPA, and other privacy regulations.
Regular Updates: Keep your Data Layer up to date with any changes in your site structure, user attributes, or analytics components to maintain data accuracy and relevance.