Enrichment¶
The datalayer has been setup and Harvest Collect detected the dataLayer. Either because the developer pushed the data with the harvest.trackEvent function or by using our data attributes library.
At that moment, Harvest Collect will start to work and enrich the default datalayer. This will result in a data object we call the final event.
harvest.trackEvent({
"event":"pageview",
"data": {}
});
If we start with the following code, we basically have the following information:
- We have an event of type pageview.
- We have no custom meta data (an empty object: {}).
This however, does not mean there is no meta data.
As can be read in the meta data documentation, there are many variables we collect by default.
So how does enrichment work?¶
Step 1 - Validation
The first step is that we do a lot of validation. Did the user provide the correct information? This is important, because we want to make sure the datalayer is not implemented incorrectly.
This first step can lead to several errors. More information about the errors can be found in the error documentation.
Then we start transforming the object that was pushed in the trackEvent function. If multiple tracking objects were pushed, we will handle them one by one.
In the example above we start with the following object:
{
"event":"pageview",
"data": {}
}
In the examples below, each object will be depicted as an empty object for simplicity.
Step 2 - consentData
The first thing we will do is obtain the consentData for this user. This is only done when in Harvest Console consent is turned on. We obtain the cnsent by checking the configured consent cookie.
Another aspect of consent is checking for sensitive pages.
After we have retrieved consentData, the object will look like this.
{
"event":"pageview",
"consentData" :{},
"data": {}
}
Step 3 - eventData
After consentData has been processed, we will copy the data-property to the eventData property. Besides that, we will add several default variables related to the current event type and data.
{
"event":"pageview",
"consentData" :{},
"eventData": {}
}
Step 4 - debugData
The next step is to add the debugData to the object. This information is very handy when debugging in Harvest Store, but can also be used in marketing tools. For example if you want to know what type of device a user has used.
{
"event":"pageview",
"consentData" :{},
"debugData" :{},
"eventData": {}
}
Step 5 - pageData
This is the first variable group that is configurable. First we will obtain a lot of information about the page, as can be seen in the meta data documentation. Besides that, we also prepare some variables that we can match with domains and pagemarkers.
To start with, we loop through all defined page data variables and each variable that is configured and is at this moment available in eventData, will be taken from eventData and put in pageData. This means that if you have not configured a variable and sent it with the event, it will stay in eventData.
After the variables are taken from eventData and put in pageData, we will check domains and page markers. For these tracking components we could have configured variable enrichment. This means that some variables in eventData and pageData will get a value, because a certain domain or pagemarker was triggered.
When a match has been made with a domain or page marker, we will save this in eventData, so we can use it with to set a tool configuration for our tools. It is possible that multiple page markers are matched.
{
"event":"pageview",
"consentData" :{},
"debugData" :{},
"eventData": {},
"pageData": {}
}
Step 6 - userData
Just as with pageData, we will create some default variables and loop through all custom variables. This will result in the userData object. During this phase, a user will be generated. For more information, read about user management.
{
"event":"pageview",
"consentData" :{},
"debugData" :{},
"eventData": {},
"pageData": {},
"userData": {}
}
Step 7 - sessionData
Just as with pageData, we will create some default variables and loop through all custom variables. This will result in the sessionData object. During the creation of sessionData, some important functions will be executed for more information, read about session management.
{
"event":"pageview",
"consentData" :{},
"debugData" :{},
"eventData": {},
"pageData": {},
"userData": {},
"sessionData": {}
}
Step 8 - funnelData
Just as with pageData, we will create some default variables and loop through all custom variables. This will result in the funnelData object.
Besides that, we will also check whether a funnelName-funnelStep combination is configured. If there is a match, we will save this in eventData and, if configured, also do the required variable enrichment to eventData or funnelData.
{
"event":"pageview",
"consentData" :{},
"debugData" :{},
"eventData": {},
"pageData": {},
"userData": {},
"sessionData": {},
"funnelData": {}
}
Step 9 - Content interactions
A special process is the checking of content interactions. When there was a match, we will save this match in eventData. We will also check for variable enrichment based on the content interaction. This enrichment can only be done for eventData variables.
{
"event":"pageview",
"consentData" :{},
"debugData" :{},
"eventData": {},
"pageData": {},
"userData": {},
"sessionData": {},
"funnelData": {}
}
Step 10 - contentData, promotionData and productData
The following enrichment step is we process contents, products and promotions if there are in the event.
The products sent with an event will only be processed when the event is related to products. If this is not the case, the products will be stripped from the events. The same goes for contents and promotions.
productDataArrays
When the event is related to products, the productDataArrays will also be generated. For each variable a product can hold, for example the name, id and quantity, we will generate an array of values. Let’s say we have the following event:
harvest.trackEvent({
"event":"content",
"data": {
"viewType":"productListView",
"products": [{
"name": "Product A",
"list": "Featured products"
},{
"name": "Product B",
"list": "Featured products"
}]
}
});
This will then result in the following productDataArrays:
{
"productNames": [ "Product A", "Product B"],
"productList": ["Featured products", "Featured products"]
}
Some tools need you to provide them with arrays for each product property instead of an array of products. The productDataArrays properties give you the option to easily provide this information.
Below you will find the object after this processing. Note depending on the variable, promotionData, productData, contentData or productDataArrays will be in the final event.
{
"event":"pageview",
"consentData" :{},
"debugData" :{},
"eventData": {},
"pageData": {},
"userData": {},
"sessionData": {},
"funnelData": {},
"promotionData": [],
"contentData": [],
"productData": [],
"productDataArrays" : {}
}
Step 11 - customProcessing
The final step in the enrichment process before setting tool configurations for tools is the custom processing.
The custom processing function is a function you can specify yourself. It can create new variables, filter variables or do anything you want.
The idea is to give you custom control.
After this step, the data will proceed to the tools.
Step 12 - Post processing tools
The first step after we have generated the tool configurations it he post processing tools. Some tools that you can configure will manipulate the final event.
An example is the Google Analytics Enhanced Ecommerce feature. This feature will add an “ecommerce” object to the final event.
Step 13 - Variable blacklisting
Last but certainly not least is the variable blacklisting function. In Harvest Console you can configure which variables should only be tracked when a user gives a certain permission.
Variable blacklisting checks each variable against the given permissions. If a variable is provided, but the consent is missing, then the variable will be deleted from the event.
After this step, the final event will be distributed or used for execution.
Variable processing¶
An important part of the enrichment process is the processing of variables. Variables are put in the correct variable groups, but also need the right values. Variables obtain their values in the following ways:
- Value is put into the datalayer.
- Value is configured in a tracking component.
- Value is obtain from environment variables (like the domain or pathname of a page).
- Value is obtained from query string parameters.