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.
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)
- Shared code
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:
- 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:
Custom action object
The custom action object contains the data of a custom action event.
Table: Custom action object properties
Name of the custom action. The name uniquely identifies the custom action.
This property maps to the Name field of a custom action in the Control Panel.
Value of the custom action. The value is case-sensitive.
This property maps to a Value field of a custom action in the Control Panel.
Custom action object examples
Testing custom action tracking
To test that custom actions are correctly tracked with the data layer:
- Go to the site.
- Launch Frosmo Preview.
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.<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
customActionmessages, 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
customActionrequest to the Events API.
Open the Frosmo Control Panel, select Utilities > 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.