# App Analytics

App Analytics allows for the collection of application and session events. This document will cover two workflows for integrating App Analytics into your Android application. Clients can choose between these two workflows depending on their needs and level of control over the session management.

It is crucial to maintain a single instance of the UnifiedPlugin across the entire app. This can be accomplished using dependency injection or by implementing a Singleton class, such as the UnifiedPluginProvider, which provides the UnifiedPlugin instance.

We have supplied the UnifiedPluginProvider as a solution to ensure that only one instance is shared throughout the app.

However, you are free to create your own solution if desired.

The two workflows are:

  1. Simple Integration Workflow
  2. Advanced Integration Workflow

# Simple Integration Workflow

This strategy is aimed at helping clients to use the App Analytics platform without having to manage the session on their own. Use the begin() and end() functions to start and stop sessions accordingly.

Internally, begin() will first start the session and then perform navigation after the session is created. This ensures navigation events are recorded within the correct session context. Thus, you don't need to manually handle navigation in the Simple Integration Workflow.

# begin: Start Session and Navigation

To start a session and perform an initial navigation, use the begin function. Optionally, you can pass the screen name and custom dimensions to be populated in the Suite.

The begin function will automatically handle the session starting and the first navigation event as part of the simple integration workflow. This makes it easier for you to focus on integrating the App Analytics platform into your Android application without worrying about explicitly managing sessions and navigation events.

# End Session

To end a session, use the end function. 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 function with the event name. You can also add custom dimensions, custom metrics, and send parameters directly in the request.

# Code Examples

# Initializing UnifiedPluginProvider (different options)

  • Java
  • Kotlin
// Initialise with account code and application instance
UnifiedPluginProvider.initialize(
    "your_account_code",
    yourApplicationInstance
);

// Initialise with account code and activity instance
UnifiedPluginProvider.initialize(
    "your_account_code",
    yourActivityInstance
);

// Initialise with account code and additional options
UnifiedPluginProvider.initialize(
    "your_account_code",
    yourApplicationInstance,
    yourVideoAnalyticsOptions,
    yourBalancerOptions,
    5 * 60 * 1000L, // diagnosticsTimeoutMilliseconds
    true, // videoDiagnosticsEnabled
    true, // cdnBalancerDiagnosticsEnabled
    Log.Level.ERROR // logLevel
);

// Initialise with a UnifiedPlugin.Builder instance
UnifiedPlugin.Builder builder = new UnifiedPlugin.Builder(
    yourApplicationInstance
    "your_account_code",
);
UnifiedPluginProvider.initialize(builder);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

# Get UnifiedPlugin from UnifiedPluginProvider

  • Java
  • Kotlin
// Get the shared UnifiedPlugin instance
UnifiedPlugin plugin = UnifiedPluginProvider.getInstance();
1
2

# Start Session (Simple Integration)

  • Java
  • Kotlin
// Start session without screen or dimensions
plugin.getAppAnalytics().begin();

// Start session / Navigation with screen name
plugin.getAppAnalytics().begin("ScreenName");

// Start session with screen name and custom dimensions
Map<String, String> dimensions = new HashMap<>();
dimensions.put("dimensionName", "dimensionValue");
plugin.getAppAnalytics().begin("ScreenName", dimensions);

// Start session forcing new session
plugin.getAppAnalytics().begin("ScreenName", null, true);
1
2
3
4
5
6
7
8
9
10
11
12
13

# End Session (Simple Integration)

  • Java
  • Kotlin
// End session without parameters
plugin.getAppAnalytics().end();

// End session with custom parameters
Map<String, String> params = new HashMap<>();
params.put("param", "paramData");
plugin.getAppAnalytics().end(params);
1
2
3
4
5
6
7

# Advanced Integration Workflow

This workflow aligns with the web implementation and exposes all functions to clients so they can call them directly. These functions include fireSessionStart(), forceNewSession(), fireNav(), fireEvent(), and fireSessionStop().

# Start Session

To start a session, use the fireSessionStart() function. Optionally, you can pass the screen name and custom dimensions to be populated in the Suite.

# Force New Session

To force a new session, use the forceNewSession() function. Optionally, you can pass the screen name and custom dimensions to be populated in the Suite.

For navigation, use the fireNav() function passing screen name after the session has started.

# Custom Events

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

# End Session

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

# Code Examples

# Start Session (Advanced Integration)

  • Java
  • Kotlin
// Start session without screen or dimensions
plugin.getAppAnalytics().fireSessionStart();

// Start session with screen name
plugin.getAppAnalytics().fireSessionStart("ScreenName");

// Start session with screen name and custom dimensions
Map<String, String> dimensions = new HashMap<>();
dimensions.put("dimensionName", "dimensionValue");
plugin.getAppAnalytics().fireSessionStart("ScreenName", dimensions);
1
2
3
4
5
6
7
8
9
10

# Force New Session (Advanced Integration)

  • Java
  • Kotlin
// Force new session without screen or dimensions
plugin.getAppAnalytics().forceNewSession();

// Force new session with screen name
plugin.getAppAnalytics().forceNewSession("ScreenName");

// Force new session with screen name and custom dimensions
Map<String, String> dimensions = new HashMap<>();
dimensions.put("dimensionName", "dimensionValue");
plugin.getAppAnalytics().forceNewSession("ScreenName", dimensions);
1
2
3
4
5
6
7
8
9
10
  • Java
  • Kotlin
// Navigate using fireNav() function
plugin.getAppAnalytics().fireNav("ScreenName");
1
2

# Session Event / Custom Session Event (Advanced Integration)

  • Java
  • Kotlin
// Fire event with name
plugin.getAppAnalytics().fireEvent("EventName");

// Fire event with custom dimensions
Map<String, String> dimensions = new HashMap<>();
dimensions.put("dimensionName", "dimensionValue");
plugin.getAppAnalytics().fireEvent("EventName", dimensions, null, null);

// Fire event with custom metrics
Map<String, Double> metrics = new HashMap<>();
metrics.put("metricName", 10.0);
plugin.getAppAnalytics().fireEvent("EventName", null, metrics, null);

// Fire event with custom params
Map<String, String> params = new HashMap<>();
params.put("param", "paramData");
plugin.getAppAnalytics().fireEvent("EventName", null, null, params);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

# End Session (Advanced Integration)

  • Java
  • Kotlin
// End session using fireSessionStop() function without params
plugin.getAppAnalytics().fireSessionStop();

// End session using fireSessionStop() function with custom params
Map<String, String> params = new HashMap<>();
params.put("param", "paramData");
plugin.getAppAnalytics().fireSessionStop(params);

1
2
3
4
5
6
7
8

By choosing the appropriate workflow according to your needs and control over the session management, you can effectively integrate App Analytics into your Android application. Make sure to use the provided code examples for a smooth integration process.

Updated: 7/5/2023, 4:47:10 PM