Customizing form event tracking customizing-form-event-tracking
Out of the box, the following events are tracked in an analytics enabled Adaptive Form:
Customizing the field visit event timeout customizing-the-field-visit-event-timeout
On the default AEM form setup, if a user spends more than 60 seconds on a field, a fieldvisit event is triggered and the details of the field are sent to Adobe Analytics. You can customize the Field time tracking baseline under AEM Forms Analytics Configuration at AEM Configuration console (https://experienceleague.adobe.com/system/console/configMgr?lang=en) to increase or decrease the timeout limit.
Customizing the tracking events customizing-the-tracking-events
You can modify the trackEventfunction available in /libs/afanalytics/js/custom.js file to customize the event tracking. Whenever an event that is being tracked occurs in an adaptive form, the trackEventfunction is called. The trackEvent function accepts two parameters: eventNameand variableValueMap.
You can evaluate value of *eventName *and variableValueMap arguments to change the tracking behavior of events. For example, you can choose to send the information to analytics server after a certain number of error events occur. You can also choose to perform any of the following customizations:
-
You can set a threshold time before sending the event.
-
You can maintain a state to decide action, for example, fieldVisit pushes a dummy event based on the timestamp of the last event.
-
You can use the
pushEventfunction to send the event to analytics server . -
You can choose to not push the event to analytics server at all.
Sample sample
In the following example, state for the error event of each *fieldName attribute is maintained. *The event is sent to the analytics server only if an error occurs again.
case 'error':
if(errorOccurred[variableValueMap.fieldName] == true) {
pushEvent(eventName, variableValueMap)
}
errorOccurred[variableValueMap.fieldName] = true;
break;
Customizing the panelvisit event customizing-the-panelvisit-event
On the default AEM Forms setup, after every 60 seconds, it is checked if the window containing the adaptive form is active. If the window is active, a panelVisitevent is triggered to Adobe Analytics. It helps in ascertaining that the document or the form is active and calculating time spent on the corresponding form or document.
You can modify the scheduleHeartBeatCheck function available in the /libs/afanalytics/js/custom.js file to change or stop this event sent to Adobe Analytics at a regular interval.