Skip to main content

Tracking data with the data layer

note

To use the data layer on a site, 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

note

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 dataLayer.push() function. The function takes a single parameter: an object representing the data you want to pass to the Frosmo JavaScript library.

The Frosmo Platform supports the following default data layer events, each with its own standard object structure:

You can call dataLayer.push() directly from your page code or from shared code.

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 completed conversion.

dataLayer.push({
conversionId: 'ebook-download-personalization',
conversionType: 'Ebook download',
conversionValue: 0,
frosmoConversionName: 'Personalization ebook download'
});
note

Basic feature setups rely on their own dedicated data layer events whose data is structured differently from the default event objects. However, under the hood, the platform converts these dedicated events to default ones.

Workflow for tracking data

The workflow for tracking visitor behavior and collecting data from a site runs as follows:

  1. A visitor completes an action that you want to track (conversion, custom action, product view, or transaction).

  2. Your code on the page calls dataLayer.push() with the appropriate data for tracking the action. The call triggers the corresponding event (conversion, custom action, product view, or transaction).

  3. The Frosmo JavaScript library catches the event and the data.

  4. The Frosmo JavaScript library sends the data to the Frosmo back end, where the platform stores the data in a database.

  5. You use the data for analytics or for implementing some feature or functionality on the site.

Example: Product tracking and recommendations

Here's an example workflow of product tracking that feeds into generating the data for a recommendation:

  1. A visitor navigates to a product page.

  2. Your code on the product page calls dataLayer.push() with the product data, which the code scrapes from the page or fetches from an external source, such a product database or feed. The call triggers a product view event.

    tip

    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 so as to ensure that the page content first gets rendered for the visitor.

  3. The Frosmo JavaScript library catches the product view event and the product data.

  4. The Frosmo JavaScript library sends the product data to the Frosmo back end, where the platform stores the data in the product database.

  5. The platform registers the data push as a view for the product, incrementing the product view count by one.

  6. You create a recommendation strategy for, for example, most viewed products.

  7. The Frosmo Recommendations engine uses the recommendation strategy, along with the collected product data and the product view counts, to generate the recommendation data.

Generating recommendations based on tracked product data
Figure: Generating recommendations based on tracked product data

For more information about the recommendation creation workflow, see Creating recommendations.