# App Analytics

App Analytics allows the collection of application and session events.

It is important to maintain only one instance of UnifiedPlugin throughout the app.

# Start Session

To start a session, use the begin method. Optionally, you can pass custom dimensions to be populated in the Suite. It also has a boolean to force a new session if set.

To start a new session when another one is still open, use the newSession or begin({}, true) method. You can also pass custom dimensions.

For navigation, use the fireNav method if you are sure the session has started.

# End Session

To end a session, use the end method. You can add parameters that will be sent in the request and populated if they are properly configured.

# Custom Events

Custom events will populate session events in the suite. To do this, call the fireEvent method with the event name. You can also add custom dimensions, custom metrics, and send parameters directly in the request.

# Code Examples

# Start Session (different options)

// Start a new session
unifiedPlugin.appAnalytics.newSession();

// Start session with custom dimensions
const dimensions = {
    'dimension1': 'value1',
    'dimension2': 'value2'
}
unifiedPlugin.appAnalytics.newSession(null, dimensions);

// Start new session with analytics options
let analyticsOptions = {
    'session.metrics': sessionMetrics
};
unifiedPlugin.appAnalytics.newSession(analyticsOptions);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Send session navigation
unifiedPlugin.appAnalytics.fireNav();

// Send session navigation with dimensions
const dimensions = {
    'dimension1': 'value1',
    'dimension2': 'value2'
}
unifiedPlugin.appAnalytics.fireNav(dimensions);
1
2
3
4
5
6
7
8
9

# Session Event / Custom Session Event (different options)

// Fire event with name
unifiedPlugin.appAnalytics.fireEvent('eventName');

// Fire event with name and custom dimensions
const dimensions = {
    'dimension1': 'value1',
    'dimension2': 'value2'
}
unifiedPlugin.appAnalytics.fireEvent('eventName', dimensions);

// Fire event with name, custom dimensions and custom metrics
let metrics = {
    'metricName': 10
}
unifiedPlugin.appAnalytics.fireEvent('eventName', dimensions, metrics);

// Fire event with name, custom dimensions, custom metrics and top level dimensions
let topDimensions = {
    'dimension': 'value'
}
unifiedPlugin.appAnalytics.fireEvent('eventName', dimensions, metrics, topDimensions);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

# Session End (different options)

// End session
unifiedPlugin.appAnalytics.endSession();

// End session with custom params
let params = {
    'param': 'value'
}
unifiedPlugin.appAnalytics.endSession(params);
1
2
3
4
5
6
7
8
Updated: 6/12/2023, 5:43:00 PM