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 product tracking in the Frosmo Platform, see Data tracking solutions#Product tracking.
Tracking products with the data layer means triggering a product view event whenever a visitor navigates to a product page or otherwise views a product on a site. The data you pass in the product view event is the product data for the viewed product.
On iGaming sites, a product view is called "game open" and a product view event is therefore "game open event". |
You can trigger product view events from:
Page code is the recommended solution. If you cannot use the data layer in your page code, use shared code.
Figure: Tracking products by triggering a product view event from a page (click to enlarge)
When you trigger a product view event, how the Frosmo Platform handles the event and the products defined in the event data depends on the event's mode setting:
mode: 'set'
:mode: 'setView'
(default):mode: 'view'
:To verify that the tracked product data is correctly stored in the Frosmo back end, view the product data in the Frosmo Control Panel.
To trigger a product view event, call the dataLayer.push()
function with the following object:
dataLayer.push({ frosmo: { view: { products: [{ /* Standard attributes */ id: '<product_id>', availability: '<product_availability>', brand: '<product_brand>', image: '<product_image_url>', name: '<product_name>', originalPrice: <product_original_price>, parentId: '<parent_product_id>', price: <product_current_price>, type: '<product_type>', url: '<product_page_url>', /* Custom attributes */ <key>: <value>, ... }], /* Optional */ mode: 'set|setView|view' } } }); |
The frosmo.view
object contains the event data.
view
objectThe view object contains the data of a single product view event.
Table: view
object properties
Property | Description | Type | Role | |
---|---|---|---|---|
products | List of viewed products. Define each product as a product object. You must define at least one product. If the list is empty, the platform ignores the event. | Array of product objects | Required | |
mode | Set how the Frosmo Platform treats the event and event data. The possible values are:
The default value is
| String | Optional |
The product object contains the data (attributes) for a single product. You can define standard attributes and custom attributes for a product.
The Frosmo Platform automatically trims string values by removing opening and ending white spaces. Empty string values are valid for all string attributes except id
.
To get the most out of the Frosmo Platform, include as many optional standard attributes in your product data as possible.
Table: Product object properties (standard attributes)
Property | Description | Type | Role | |||
---|---|---|---|---|---|---|
id | Product ID.
| String (256) | Required | |||
availability | Product availability in the web store. The possible values are:
If you provide a value other than one of those listed, the data layer push fails, and no product data is updated. | String | Optional | |||
availableOn | Date and time when the product becomes or has become available to visitors, for example, for purchase. This property typically indicates how new the product is to the site. | Datetime string (ISO 8601) | Optional | |||
brand | Brand name for the product, or the company that produces the product. | String (2048) | Optional | |||
categories | Categories to which the product belongs. This can also be keywords, tags, types, or any other set of classifiers used on the site. You can define a hierarchy of parent and child categories as a breadcrumb using
The maximum stringified length for the array is 2048 characters.
| Array of strings (2048) | Optional | |||
image | Product image URL.
| String (2048) | Optional | |||
name | Product name.
| String (256) | Optional | |||
originalPrice | Original unit price for the product. Use this property for the original starting price before any discounts. | Number | Optional | |||
parentId | ID of the parent product, if the current product is a product variant. If your site has a product feed that provides the baseline product data to the Frosmo Platform, you can omit this parameter or set it to If your site does not have a product data feed, and if you know the ID of the parent product, use this property to define the current product as a variant of the parent.
For recommendation generation purposes, the platform calculates product variant statistics (views, conversions, transactions) for the parent product. Recommendations only return parent products (as they contain the combined statistics for a product). | String (256) | Optional | |||
price | Current unit price for the product, such as a discount price.
| Number | Optional | |||
type | Product category. This can also be a keyword, tag, type, or any other form of classification used on the site. Define a hierarchy of parent and child categories as a breadcrumb using
| String (256) | Optional | |||
url | Product page URL.
| String (2048) | Optional |
If the standard attributes are not sufficient to track your product data, define the necessary custom attributes to complement the standard ones. You can freely define as many custom attributes as you need for your products.
A custom attribute must meet the following requirements:
The attribute name must be a string with a length of 1-32 characters. If the name is empty or longer than 32 characters, the platform ignores the product.
The platform automatically trims leading and trailing spaces from the attribute name. The platform validates the length of the trimmed name. |
The attribute name cannot be any of the following:
created_at
feed_updated_at
updated_at
These names are reserved for read-only attributes that the platform automatically creates and updates for a product. If you include any of these attributes in the product object, the platform ignores the entire product view event.
null
.If the custom attribute is an object, the object properties can be anything you want them to be. The Frosmo Platform does not validate the properties against any data model or schema.
You cannot filter recommendation data by object properties. If you want to use a custom attribute for filtering recommendations, use one of the other supported data types. |
dataLayer.push({ frosmo: { view: { products: [{ id: '123', availability: 'in stock', brand: 'Mr. Fruit', image: 'https://shop.company.com/images/products/product-123.png', name: 'Coconut', originalPrice: 5.00, price: 3.00, type: 'Food/Fruits', url: 'https://shop.company.com/products/123' }] } } }); |
dataLayer.push({ frosmo: { view: { products: [{ id: '678', availability: 'in stock', brand: 'Veggieman', categories: [ 'Food/Fruits', 'Food/Vegetables' ], image: 'https://shop.company.com/images/products/product-678.png', name: 'Tomato', originalPrice: 1.00, price: 1.00, type: '', url: 'https://shop.company.com/products/678' }] } } }); |
dataLayer.push({ frosmo: { view: { products: [{ id: '345', availability: 'in stock', brand: 'Wakita', image: 'https://shop.company.com/images/products/product-1.jpg', name: 'Electric Planer Brandix KL370090G 300 Watts', originalPrice: 749.00, price: 509.32, type: 'Power Tools/Woodworking', url: 'https://shop.company.com/products/345', /* Custom attributes */ badges: [ 'new', 'sale' ], features: [ { name: 'Battery capacity', value: '2 A-h' }, { name: 'Battery type', value: 'Li-ion' }, { name: 'Battery voltage', value: '20 V' }, { name: 'Electric motor type', value: 'Brushless DC' }, { name: 'Speed', value: '750 RPM' } ], stock: 100 }] } } }); |
/* Parent product */ dataLayer.push({ frosmo: { view: { products: [{ id: '1001', availability: 'in stock', brand: 'Lumberland', image: 'https://shop.company.com/images/products/product-1001.png', name: 'Casual Engineer Boots', originalPrice: 350.00, price: 290.00, type: 'Fashion/Shoes', url: 'https://shop.company.com/products/1001', color: 'Black' }] } } }); /* Product variant 1 */ dataLayer.push({ frosmo: { view: { products: [{ id: '1002', availability: 'in stock', brand: 'Lumberland', image: 'https://shop.company.com/images/products/product-1002.png', name: 'Casual Engineer Boots', originalPrice: 350.00, parentId: '1001', price: 290.00, type: 'Fashion/Shoes', url: 'https://shop.company.com/products/1002', color: 'Brown' }] } } }); /* Product variant 2 */ dataLayer.push({ frosmo: { view: { products: [{ id: '1003', availability: 'in stock', brand: 'Lumberland', image: 'https://shop.company.com/images/products/product-1003.png', name: 'Casual Engineer Boots', originalPrice: 350.00, parentId: '1001', price: 290.00, type: 'Fashion/Shoes', url: 'https://shop.company.com/products/1003', color: 'White' }] } } }); |
dataLayer.push({ frosmo: { view: { products: [{ id: '123', availability: 'in stock', brand: 'Mr. Fruit', image: 'https://shop.company.com/images/products/product-123.png', name: 'Coconut', originalPrice: 5.00, price: 3.00, type: 'Food/Fruits', url: 'https://shop.company.com/products/123' }], mode: 'set' } } }); |
dataLayer.push({ frosmo: { view: { products: [{ id: '321', brand: 'Microgaming', image: 'https://casino.com/images/games/agent-jane-blonde-returns.png', name: 'Agent Jane Blonde Returns', type: 'Slots/Themed', url: 'https://casino.com/games/agent-jane-blonde-returns/launch' }] } } }); |
dataLayer.push({ frosmo: { view: { products: [{ id: '321', brand: 'Microgaming', categories: [ 'Jackpots/Slot Jackpots', 'Slots/Themed' ], image: 'https://casino.com/images/games/agent-jane-blonde-returns.png', name: 'Agent Jane Blonde Returns', type: '', url: 'https://casino.com/games/agent-jane-blonde-returns/launch' }] } } }); |
dataLayer.push({ frosmo: { view: { products: [{ /* Standard attributes */ id: '321', brand: 'Microgaming', image: 'https://casino.com/images/games/agent-jane-blonde-returns.png', name: 'Agent Jane Blonde Returns', type: 'Slots/Themed', url: 'https://casino.com/games/agent-jane-blonde-returns/launch', /* Custom attributes */ badges: [ 'new' ], features: [ 'respins', 'wilds' ], paylines: 15, reels: 5, rtp: 96.5, volatility: 'low' }] } } }); |
For instructions on how to test that products are correctly tracked on a site, see Testing data tracking#Product tracking.
Do not use this method if you are preparing a site for integration with the Frosmo Platform. |
This section documents the legacy method for tracking products with the data layer. This method is officially deprecated, and the documentation is no longer maintained. If your site still uses this method, it is recommended that you migrate to the current solution. Contact Frosmo support to discuss the migration.
To trigger a product view event, call the
Product object (deprecated)The product object contains the data (attributes) for a single product. Table: Product object properties
Product object examples (deprecated)Retail
iGaming
|