To use the data layer with the Frosmo Platform, the data layer module must be enabled for the site.
No matter what data you collect with the data layer, the tracking process always follows the same basic steps, and you always handle the tracked data in the same way.
Pushing data to the data layer
Pushing incorrectly structured data to the data layer does not break or disrupt the Frosmo Platform in any way. The platform simply ignores invalid data.
To push data to the data layer, use the
- Custom action
You can call
dataLayer.push() directly from your page code or from a modification. The modification need not display any content if you simply use it to collect data.
The following example shows you how to push a conversion object to the data layer. The call triggers a conversion event and sends the conversion data to the Frosmo back end. Tracking conversions essentially means making similar calls across your site whenever a visitor does something that you want to track as a conversion.
For more information about pushing different types of data to the data layer, see:
- Tracking conversions and transactions with the data layer
- Tracking custom actions with the data layer
- Tracking products with the data layer
Process flow for tracking data
The process for tracking visitor behavior and collecting data from a site flows as follows:
- A visitor completes an action that you want to track (conversion or transaction, custom action, or product view).
- Your code on the page calls
dataLayer.push()with the appropriate data for tracking the action. The call triggers the corresponding event (conversion or transaction, custom action, or product view).
- You use the data for analytics or for implementing some feature or functionality on the site.
Example: Product tracking
Here's an example process for product tracking that feeds into a product recommendation:
- A visitor navigates to a product page. The page loads in the visitor's browser.
Your code on the product page calls
dataLayer.push()with the product data, which the code scrapes from the page. The call triggers a product view event.
Since the purpose of product tracking is to both collect product data and register product views, the
dataLayer.push()call could be placed at the end of the page source code or triggered only after the DOM is ready to ensure that the page content gets rendered first.
- You create a recommendation for most viewed products.
- The Frosmo Recommendations engine uses the collected product data and product view counts to generate the recommendation data.
Monitoring the data layer
You can monitor the data layer for data pushes. Every
dataLayer.push() call on a page triggers a
dataLayer event, which you can listen to. You can use the event to fire a trigger, or you can handle the event with your own code. To access the data that was pushed, simply get the last item in the
dataLayer array when you handle the event.
For example, if you want to know when services other than the Frosmo Platform push data to the data layer, track the
The actual event name is
frosmo.easy.EVENT_DATALAYER, but the event is exposed as
dataLayer, which is a string value that you can reference.
The following figure shows an example of a trigger that uses the Data layer event evaluation point. With this evaluation point, the trigger gets fired every time the
dataLayer event occurs on a page. You can use the trigger rules to target only certain events.
Figure: Trigger for tracking data layer events