To use the data layer on a site, the data layer module must be enabled for the site. |
You can only track basic custom actions with the data layer. To track visitor geolocation with custom actions, create the actions in the Frosmo Control Panel. |
For an introduction to custom actions and custom action tracking in the Frosmo Platform, see Data tracking solutions. For more information about custom actions, see Feature: Custom action.
Tracking custom actions with the data layer means triggering a custom action event whenever a visitor successfully completes an action or enters a state that qualifies as a custom action. The data you pass in the custom action event (a name and a value) defines the custom action.
You can trigger custom action events from:
Page code is the recommended solution. If you cannot use the data layer in your page code, use shared code.
Figure: Tracking custom actions by triggering a custom action event from a page (click to enlarge)
When you trigger a custom action event:
To trigger a custom action event, call the dataLayer.push()
function with a custom action object containing the custom action data:
dataLayer.push({ frosmoEvent: 'string', frosmoValue: 'string' }); |
The custom action object contains the data of a custom action event.
Table: Custom action object properties
Property | Description | Type | Role | |
---|---|---|---|---|
frosmoEvent | Name of the custom action. The name uniquely identifies the custom action.
| String (128) | Required | |
frosmoValue | Value of the custom action. The value is case-sensitive.
| String (128) | Required |
dataLayer.push({ frosmoEvent: 'Cookie policy accepted', frosmoValue: 'true' }); |
// Set the productCategory variable dataLayer.push({ frosmoEvent: 'Product category', frosmoValue: productCategory }); |
To test that custom actions are correctly tracked with the data layer:
Select Advanced > Events.
Go to a page where custom actions are tracked. If custom action events are successfully triggered with the data layer, Frosmo Preview shows the following messages for each event:
customAction
/ customAction.<frosmoEvent>
/ customAction.<frosmoEvent>.<frosmoValue>
(contains the custom action data parsed from the custom action 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)customAction
messages, as both columns show the custom action name and value.If you want more details on a data layer call, select the Advanced > Requests view in Frosmo Preview, and check the customAction
request to the Events API.
In the sidebar, select More > Custom Actions, and check whether the tracked custom actions are listed with the passed values.
If you define titles for the custom action values in the Control Panel, the custom actions overview displays the titles rather than the values. |