Tracking transactions with the data layer
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 transactions and transaction tracking in the Frosmo Platform, see Data tracking solutions.
Tracking transactions with the data layer means triggering a transaction event whenever a visitor successfully completes an action that qualifies as a transaction. The data you pass in the transaction event defines the transaction.
On iGaming sites, a transaction is called "game play" and a transaction event is therefore "game play event".
You can trigger transaction events from:
-
Page code (meaning directly from the site source code)
Page code is the recommended solution. If you cannot use the data layer in your page code, use shared code.
Triggering transaction events
To trigger a transaction event, call the dataLayer.push()
function with a transaction object containing the transaction data:
dataLayer.push({
transactionId: 'string',
transactionProducts: [{
id: 'string',
name: 'string',
price: 0,
sku: 'string',
/* Optional */
quantity: 0
}],
transactionTotal: 0
});
Transaction object
The transaction object contains the data of a single transaction event.
Property | Description | Type | Role |
---|---|---|---|
| Unique transaction ID. note The platform registers a transaction with a given ID only once. If you trigger a transaction event with the same ID multiple times, the platform ignores all but the first event. | String (128) | Required |
| List of products purchased in the transaction. Define each product as a transaction product object. You must define at least one product. If the list is empty, the platform ignores the event. | Array of transaction product objects | Required |
| Total purchase value of the transaction. note If the total purchase value of the transaction does not match the combined value of the products included the transaction, as recorded in the array of transaction product objects (see the following table), the total revenues listed in modification statistics will differ from the total revenues listed in segment statistics. This is because modification statistics calculate revenue based on individual product prices ( The total purchase value of the transaction may not match the combined value of the products included the transaction if, for example, the total purchase value includes a discount that is not reflected in the product data (either in the individual product prices or as a separate product with a negative price). | Number | Required |
Transaction product object
The transaction product object contains the data (attributes) of a single product included in a transaction.
Property | Description | Type | Role |
---|---|---|---|
| Product ID. The product ID is the same value you pass in the This property is optional if note If you do not use the proper product ID as the property value, the platform has no way of mapping the purchased product to the corresponding product in the Frosmo product database. For example, if you wanted to create a product recommendation based on the transactions, the recommendation engine would not be able to map the purchased products to tracked products and would therefore fail to return the product data for the transactions. | String (256) | Required (if |
| Product name. The product name is the same value you pass in the This property is optional if | String (128) | Required (if |
| Unit price used for the product in the transaction. | Number | Required |
| Stock keeping unit (SKU) code for the product. This property is optional if | String (128) | Required (if |
| Number of items purchased in the transaction. | Number | Optional |
Transaction examples
dataLayer.push({
transactionId: '1010101010',
transactionProducts: [{
id: '123456',
name: 'Cheetah Plushy',
price: 9.99,
quantity: 3
}],
transactionTotal: 29.97
});
dataLayer.push({
transactionId: '1010101011',
transactionProducts: [{
id: '123456',
name: 'Cheetah Plushy',
price: 9.99,
quantity: 3
}, {
id: '123457',
name: 'Lion Plushy',
price: 19.99,
quantity: 2
}],
transactionTotal: 69.95
});
Testing transaction tracking
For instructions on how to test that transactions are correctly tracked on a site, see Testing data tracking.