Tracking custom actions with the data layer
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 a custom action, create the action 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 (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.
When you trigger a custom action event:
-
If the custom action does not exist in the database, meaning a custom action with the same name does not already exist in the database, the Frosmo Platform adds the event data (name and value) as a new custom action.
-
If a custom action with the same name already exists in the database, and if that name is not already associated with the passed value, the Frosmo Platform adds the value to the existing custom action.
-
If a custom action with the same name already exists in the database, and if that name is already associated with the passed value, the Frosmo Platform merely triggers the custom action event. The platform does not add any new event data to the database.
Triggering custom action events
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'
});
Custom action object
The custom action object contains the data of a custom action event.
Property | Description | Type | Role |
---|---|---|---|
| Name of the custom action. The name uniquely identifies the custom action. info This property maps to the Name field of a custom action in the Frosmo Control Panel. | String (128) | Required |
| Value of the custom action. The value is case-sensitive. info This property maps to a Value field of a custom action in the Frosmo Control Panel. | String (128) | Required |
Custom action examples
dataLayer.push({
frosmoEvent: 'Cookie policy accepted',
frosmoValue: 'true'
});
// Set the productCategory variable
dataLayer.push({
frosmoEvent: 'Product category',
frosmoValue: productCategory
});
Testing custom action tracking
To test that custom actions are correctly tracked with the data layer:
-
Go to the site.
-
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)
-
-
To verify that the correct custom action data was sent, check the Name or Data column for the
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.
noteIf you define titles for the custom action values in the Control Panel, the custom actions overview displays the titles rather than the values.