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 pushEvent function to send the event to analytics server .

  • You can choose to not push the event to analytics server at all.

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;