Data Layer configuration
Detailed Edgee Data Layer guide
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.
Introduction to Edgee Data Layer
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.
Inserting a Data Layer in your application
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.
Structure of a Data Layer object
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:
Data Layer fields breakdown
The following fields are defined under data_collection
:
Field | Type | Description | |
---|---|---|---|
events | optional | Array | Contains a list of events (see below for the event structure). |
context | optional | Object | Contains general information that can be used for all events. |
components | optional | Object | Specifies which components should receive the data. This enables targeted data transmission based on your configuration. |
Let’s have a look at each field individually.
The events
list
It contains objects with the following structure.
Field | Type | Description | |
---|---|---|---|
type | required | String | The type of event: page , track , or user . |
data | optional | Object | The data structure depends on the event type (see detailed pages). This is required for track events. |
components | optional | Object | Specifies which components should receive the data. |
Learn more about the page, track, and user event types and their structure.
The context
object
It can contain the following fields.
Field | Type | Description | |
---|---|---|---|
page | optional | Object | 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.
The components
object
It can contain the following fields.
Field | Type | Description | |
---|---|---|---|
all | optional | Boolean | Even if you don’t define this field, it will be set to true by default. But if you set it to false , no destination will receive the data. |
<component_name> | optional | Boolean | If true , the specified destination will receive the data. If false , the destination 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.
Examples of valid Data Layer objects
Minimal Data Layer
Data Layer with context
Data Layer with destinations control
Best Practices
- 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.