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 product tracking in the Frosmo Platform, see Data tracking overview.

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.

You can trigger product view 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.

Figure: Tracking products by triggering a product view event from a page (click to enlarge)

When you trigger a product view event:

  • If the product is not in the product database, the Frosmo Platform adds the event data to the database as a new product. The platform uses the product ID to uniquely identify the product.
  • If the product is already in the product database, and if the event data differs from the product data in the database, the Frosmo Platform updates the data in the database. The platform only updates product attributes whose values differ and adds attributes that do not already exist in the database. The platform does not remove existing product attributes that are missing from the event data.
  • If the product is already in the product database, and if the event data does not differ from the product data in the database, the Frosmo Platform ignores the event data.
  • By default, the Frosmo Platform increments the view count for the product by one. For a newly added product, this is the first view for the product.

To check that the product data is correctly stored in the Frosmo back end, call the Product API.

Triggering product view events

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> | '<PRODUCT_ORIGINAL_PRICE>',
                price: <PRODUCT_CURRENT_PRICE> | '<PRODUCT_CURRENT_PRICE>',
                type: '<PRODUCT_TYPE>',
                url: '<PRODUCT_PAGE_URL>',

                /* Custom attributes */
                <key>: <value>,
                ...
            }]
        }
    }
});

The product data is stored in the frosmo.view.products array of product objects. You can send the data for one or more products in a single event.

Product object

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.

Standard attributes

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)

PropertyDescriptionTypeRole
id

Product ID.

The value must be a non-empty string.

String (256)Required
availability

Product availability in the web store.

The possible values are:

  • in stock
  • out of stock
  • preorder

If you provide a value other than one of those listed, the data layer push fails, and no product data is updated.

StringOptional
brandBrand 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 / as the separator. For example:

  • Electronics/Televisions/OLED
  • Electronics/Televisions/OLED/4K
  • Electronics/Televisions/Smart

The maximum stringified length for the array is 2048 characters.

If you only need to define a single category for a product, use the type attribute instead.

If you need to define a main category and one or more additional categories for a product, use the type attribute for the main category and this attribute for the additional categories.

Array of strings (2048)Optional
image

Product image URL.

Even if you do not have a value for this property, it is recommended that you nonetheless pass an empty string.

String (2048)Optional
name

Product name.

Even if you do not have a value for this property, it is recommended that you nonetheless pass an empty string.

String (128)Optional
originalPrice

Original unit price for the product.

Use this property for the original starting price before any discounts.

If the value is a string that can be represented as a number, the Frosmo Platform stores the value as a number.

Number | String (2048)Optional
price

Current unit price for the product, such as a discount price.

Even if you do not have a value for this property, it is recommended that you nonetheless pass an empty string.

If the value is a string that can be represented as a number, the Frosmo Platform stores the value as a number.

Number | String (2048)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 / as the separator. For example: Electronics/Televisions/OLED

Even if you do not have a value for this property, it is recommended that you nonetheless pass an empty string. This property can be used in segmentation rules and therefore needs to have a value.

If you need to define multiple categories for a product, use the categories attribute instead, and set this attribute to an empty string.

If you need to define a main category and one or more additional categories for a product, use this attribute for the main category and the categories attribute for the additional categories.

String (128)Optional
url

Product page URL.

Even if you do not have a value for this property, it is recommended that you nonetheless pass an empty string.

String (2048)Optional

Custom attributes

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 maximum length of 32 characters.
  • The data type of the attribute value must be one of the following:
    • Array
    • Boolean
    • Number
    • Object
    • String
  • The attribute value can also be 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.

Product object examples

Retail

Example: Retail product with standard attributes (single category)
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'
            }]
        }
    }
});
Example: Retail product with standard attributes (multiple categories)
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'
            }]
        }
    }
});
Example: Retail product with standard and custom attributes
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
            }]
        }
    }
});

iGaming

Example: Casino game with standard attributes (single category)
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'
            }]
        }
    }
});
Example: Casino game with standard attributes (multiple categories)
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'
            }]
        }
    }
});
Example: Casino game with standard and custom attributes
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'
            }]
        }
    }
});

Testing product tracking

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

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

    Testing product tracking

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

    • product (contains the product data parsed from a single product 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 product tracking

    Product view events log a dedicated product message for each product object in the frosmo.view.products array.

  5. To verify that the correct product data was sent, check the dataLayer message.

    Testing product tracking

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

    Testing product tracking

Triggering product view events (deprecated method)

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. 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 dataLayer.push() function with a product object containing the product data:

dataLayer.push({
    frosmoProductId: 'string',
    /* Optional */
    frosmoProductCategory: 'string',
    frosmoProductData: {},
    frosmoProductDiscountPrice: 0,
    frosmoProductImage: 'string',
    frosmoProductName: 'string',
    frosmoProductPrice: 0,
    frosmoProductPromotionLabel: 'string',
    frosmoProductUrl: 'string'
    /* ... */
});

Product object (deprecated)

The product object contains the data (attributes) for a single product.

Table: Product object properties

PropertyDescriptionTypeRole
frosmoProductId

Product ID.

The Frosmo Platform uses the product ID to uniquely identify the product.

String (256)Required
frosmoProductArea

Geographical region, typically a part of a country, that applies to the product in some way.

For example, if the product is a hotel room, this property can provide the name of the in-country region in which the hotel is located:

  • frosmoProductCountry: Greece
  • frosmoProductArea: Rhodes
  • frosmoProductCity: Lindos
String (32)Optional
frosmoProductCampaignSales or other campaign with which the product is associated.String (32)Optional
frosmoProductCategories

Additional product categories to which the product belongs.

For more information about the object type, see the instructions below this table.

One of:

  • Array of strings
  • Stringified array of strings (1024)
  • Object
  • Stringified object (1024)
Optional
frosmoProductCategory

Product category or type.

Even if you do not have a value for this property, it is recommended that you nonetheless pass an empty string. This property can be used in segmentation rules and therefore needs to have some value.

String (128)Optional
frosmoProductCity

City or town that applies to the product in some way.

For example, if the product is a hotel room, this property provides the name of the city or town in which the hotel is located:

  • frosmoProductCountry: Greece
  • frosmoProductArea: Rhodes
  • frosmoProductCity: Lindos
String (32)Optional
frosmoProductColors

Color options for the product.

For more information about the object type, see the instructions below this table.

One of:

  • Object
  • Stringified object (1024)
Optional
frosmoProductCompanyCompany that offers the product.String (32)Optional
frosmoProductConversion

If you want to merely send the product data to the Frosmo back end without triggering a product view event, set this property to 1. In this case, the Frosmo Platform does not increment the view count for the product, but instead just stores the product data.

The default value is 0, which means that the Frosmo Platform also registers the product data push as a product view.

Despite the name, this property does not trigger a conversion event for the product, regardless of the property value. If you want to register a conversion for the product, trigger a conversion event or transaction event instead.

NumberOptional
frosmoProductCountry

Country that applies to the product in some way.

For example, if the product is a hotel room, this property provides the name of the country in which the hotel is located:

  • frosmoProductCountry: Greece
  • frosmoProductArea: Rhodes
  • frosmoProductCity: Lindos
String (32)Optional
frosmoProductCustomImages

URLs of additional product images.

For more information about the object type, see the instructions below this table.

One of:

  • Object
  • Stringified object (2048)
Optional
frosmoProductData

Any piece of product data that does not logically belong to the other product properties but that you want to push with the product data. Use this property to send your own custom product attributes along with the product data.

For more information about the object type, see the instructions below this table.

One of:

  • Object
  • Stringified object (2048)
Optional
frosmoProductDescriptionProduct description.String (512)Optional
frosmoProductDiscountPriceDiscount unit price for the product.String (32)Optional
frosmoProductIds

Additional product IDs.

For example, if the product consists of multiple child products, you can add their IDs to this property.

For more information about the object type, see the instructions below this table.

One of:

  • Object
  • Stringified object (1024)
Optional
frosmoProductImage

Product image URL.

Even if you do not have a value for this property, it is recommended that you nonetheless pass an empty string.

String (512)Optional
frosmoProductMainCategoryMain product category to which the product belongs.String (128)Optional
frosmoProductManufacturerCompany that produces the product, or the brand name for the product.String (512)Optional
frosmoProductModelProduct model name.String (32)Optional
frosmoProductMultiPrices

Additional unit price options for the product.

For more information about the object type, see the instructions below this table.

One of:

  • Object
  • Stringified object (2048)
Optional
frosmoProductName

Product name.

Even if you do not have a value for this property, it is recommended that you nonetheless pass an empty string.

String (128)Optional
frosmoProductPrice

Unit price for the product.

Even if you do not have a value for this property, it is recommended that you nonetheless pass an empty string.

String (32)Optional
frosmoProductPromotionLabel

Promotion-related label, such as "Weekend Sale" or "80% off!".

This property is intended for promotion-related label strings. Do not use this property for stringified objects. If you need to store extra product data beyond the standard product data properties listed here, use the frosmoProductData property.

String (512)Optional
frosmoProductRatingProduct rating.String (512)Optional
frosmoProductStockNumber of product units in stock.NumberOptional
frosmoProductSubCategory

Subcategory to which the product belongs. The subcategory should be a child category of the main product category.

For example, if the main product category is "Children", the subcategory could be "Clothes" or "Toys".

String (128)Optional
frosmoProductUrl

Product page URL.

Even if you do not have a value for this property, it is recommended that you nonetheless pass an empty string.

String (512)Optional
frosmoProductUrnUniform Resource Names (URN) for the product.String (32)Optional
frosmoProductVenue

Venue in which the product is available.

For example, if the product is a specific showing of a movie, this property would be the movie theater in which the movie is shown.

String (64)Optional

Objects

Follow these rules for product object properties whose type is object:

  • The value can be either a JavaScript object or a JSON-stringified object. In the latter case, the maximum length of the string is either 1024 or 2048 characters, depending on the property (see above).
  • The properties of the object can be anything you want them to be. The Frosmo Platform does not validate the properties against any data model or schema.

If you assign a JavaScript object to a product object property, the Frosmo Platform stringifies the value. If you assign a stringified object to a property, the platform stores the value as-is.

Product object examples (deprecated)

Retail

Example: Triggering a product view event with a simple product object
dataLayer.push({
    frosmoProductId: '123456',
    frosmoProductCategory: 'Plushies',
    frosmoProductDiscountPrice: 9.99,
    frosmoProductImage: '/images/cheetah_plushy.png',
    frosmoProductName: 'Cheetah Plushy',
    frosmoProductPrice: 19.99,
    frosmoProductPromotionLabel: 'Weekend Sale',
    frosmoProductUrl: '/products/123456'
});
Example: Triggering a product view event with a product object containing an object property
/* frosmoProductColors is a JavaScript object */

dataLayer.push({
    frosmoProductId: '123456',
    frosmoProductCategory: 'Plushies',
    frosmoProductDiscountPrice: 9.99,
    frosmoProductImage: '/images/cheetah_plushy.png',
    frosmoProductName: 'Cheetah Plushy',
    frosmoProductPrice: 19.99,
    frosmoProductPromotionLabel: 'Weekend Sale',
    frosmoProductUrl: '/products/123456',
    frosmoProductColors: {
        black: '#000000',
        blue: '#0000ff',
        lime: '#00ff00',
        red: '#ff0000'
    }
});

/* frosmoProductColors is a JSON-stringified object */

dataLayer.push({
    frosmoProductId: '123456',
    frosmoProductCategory: 'Plushies',
    frosmoProductDiscountPrice: 9.99,
    frosmoProductImage: '/images/cheetah_plushy.png',
    frosmoProductName: 'Cheetah Plushy',
    frosmoProductPrice: 19.99,
    frosmoProductPromotionLabel: 'Weekend Sale',
    frosmoProductUrl: '/products/123456',
    frosmoProductColors: '{"black":"#000000","blue":"#0000ff","lime":"#00ff00","red":"#ff0000"}'
});
Example: Triggering a product view event with minimal data and without incrementing the view count for the product
dataLayer.push({
    frosmoProductId: '123456',
    frosmoProductConversion: 1
});
Example: Triggering a product view event with multiple product categories for recommendation filtering
dataLayer.push({
    frosmoProductId: '234567',
    frosmoProductCategory: '',
    frosmoProductCategories: [
        'Accessories',
        'Bedding',
        'Toys'
    ],
    frosmoProductImage: '/images/cheetah_pillow.png',
    frosmoProductName: 'Cheetah Pillow',
    frosmoProductPrice: 29.99,
    frosmoProductUrl: '/products/234567'
});

iGaming

Example: Triggering a product view event where the product is a bet on a sporting event
dataLayer.push({
    frosmoProductId: 'bet-1234567', // Bet Id
    frosmoProductCategory: 'Football/Germany/Bundesliga', // Combination of main event information
    frosmoProductCountry: 'Germany',
    frosmoProductData: {
        date: '2020-06-12 21:30:00'
    },
    frosmoProductMainCategory: 'Football', // Event category (here, sport name)
    frosmoProductModel: 'Live', // Event type
    frosmoProductName: 'TSG Hoffenheim - RB Leipzig', // Event name
    frosmoProductUrl: '/event/1006388033', // Event URL
    frosmoProductVenue: 'Bundesliga' // Event venue (here, sports league)
});

Checking that the product data is in the Frosmo back end

If you want to verify that the product data you're tracking is correctly stored in the Frosmo back end, try retrieving the data with the Product API.

The Product API nests all product attributes inside the attributes property, except for id, name, and type, which are returned in the product object root.

Example: Retrieving the product data with the Product API
# Request the data for product ID 345

GET https://example.frosmo.com/productApi?method=fetch&
    origin=shop_company_com&
    ids=["345"]

# cURL command line for the above (replace the domain, origin, and product ID with proper values)

curl -X GET 'https://example.frosmo.com/productApi?method=fetch&origin=shop_company_com&ids=\["345"\]'

# Response for product ID 345, if the product exists

{
  "data": [
    {
      "id": "345",
      "type": "Power Tools/Woodworking",
      "name": "Electric Planer Brandix KL370090G 300 Watts",
      "created_at": "2021-06-08T13:26:37+03:00",
      "updated_at": "2021-06-08T14:27:11+03:00",
      "attributes": {
        "availability": "in stock",
        "badges": [
          "new",
          "sale"
        ],
        "brand": "Wakita",
        "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"
          }
        ],
        "image": "https://shop.company.com/images/products/product-1.jpg",
        "originalPrice": 749,
        "price": 509.32,
        "stock": 100,
        "url": "https://shop.company.com/products/345"
      }
    }
  ]
}