Pages

This guide is for developers who want to set up data tracking using the default data layer events supported by the Frosmo Platform. If your site has or is getting a basic feature setup from Frosmo, see the appropriate site preparation guide instead. Basic feature setups rely on their own dedicated data layer events.

To use the data layer on a site, the data layer module must be enabled for the site.

For an introduction to conversions and conversion tracking in the Frosmo Platform, see Data tracking overview.

Tracking conversions with the data layer means triggering a conversion event whenever a visitor successfully completes an action that qualifies as a conversion. The data you pass in the conversion event defines the conversion.

You can trigger conversion events from:

  • Page code (meaning directly from your site source code)
  • Shared code

Page code is the recommended solution. If you cannot use the data layer in your page code, use shared code.

Tracking conversions by triggering a conversion event from a page

Figure: Tracking conversions by triggering a conversion event from a page (click to enlarge)

Triggering conversion events

To trigger a conversion event, call the dataLayer.push() function with a conversion object containing the conversion data:

dataLayer.push({
    conversionId: 'string',
    conversionType: 'string',
    conversionValue: 0,
    frosmoConversionName: 'string'
});

Conversion object

The conversion object contains the data of a single conversion event.

Table: Conversion object properties

PropertyDescriptionTypeRole
conversionId

Conversion ID.

If you're tracking a product conversion, use the product ID as the conversion ID. The product ID is the same value you pass in the id property of a product object when tracking products.

If you're tracking a product conversion, and if you do not use the product ID as the conversion ID, the platform has no way of mapping the conversion to the corresponding product in the Frosmo product database. For example, if you wanted to create a product recommendation based on the conversions, the recommendation engine would not be able to map the conversions to tracked products and would therefore fail to return the product data for the conversions.

String (128)Required
conversionType

Conversion type.

If you're tracking a product conversion, use the product category as the conversion type. The product category is the same value you pass in the type property of a product object.

String (128)Required
conversionValue

Monetary value of the conversion (in the currency set for your site).

If you're tracking a product conversion, this property should not reflect the product price, but rather some other monetary value associated with the conversion, as this property does not map to any product data.

If you want to track a purchase-based product conversion, trigger a transaction event instead.

NumberRequired
frosmoConversionName

Conversion description.

If you're tracking a product conversion, use the product name as the conversion description. The product name is the same value you pass in the name property of a product object.

String (128)Required

Conversion object examples

Example: Triggering a conversion event
dataLayer.push({
    conversionId: 'ebook-download-personalization',
    conversionType: 'Ebook download',
    conversionValue: 0,
    frosmoConversionName: 'Personalization ebook download'
});
Example: Triggering a product conversion event
// Set the product data variables...

dataLayer.push({
    conversionId: productId,
    conversionType: productType,
    conversionValue: 0,
    frosmoConversionName: productName
});

Testing conversion tracking

To test that conversions are correctly tracked with the data layer:

  1. Go to the site.
  2. Launch Frosmo Preview.
  3. Select Advanced > Events.

    Testing conversion tracking

  4. Go to a page where conversions are tracked. If conversion events are successfully triggered with the data layer, Frosmo Preview shows the following messages for each event:

    • conversion (contains the conversion data parsed from the conversion object)
    • dataLayer (contains the object passed to the data layer)
    • trigger.event (contains information about the triggered event, including the object passed to the data layer)

    Testing conversion tracking

  5. To verify that the correct conversion data was sent, check the conversion and/or dataLayer messages.

    Testing conversion tracking

  6. If you want more details on a data layer call, select the Advanced > Requests view in Frosmo Preview, and check the setProductData and buyProduct requests to the Optimizer API.

    Testing conversion tracking

    Triggering a conversion does not trigger a product view nor a transaction event. Frosmo Core merely uses the setProductData and buyProduct events to pass the conversion data to the Frosmo back end.