SNMobileAnalytics API
-
- UpdatedFeb 1, 2024
- 1 minute read
- Washington DC
- API reference
The SNMobileAnalytics API provides methods that you can call within a WebView using JavaScript. These methods enable you to push custom analytics data (events, pages, and user properties) to the User Experience Analytics for Service Portal dashboard.
To use these methods within your mobile application, you must first call the installJavascriptInterface() method, which exposes these JavaScript methods to the associated WebView.
Refer to NowAnalyticsService - installJavascriptInterface(into webView: WKWebView) for the iOS implementation.
Refer to NowAnalyticsSDK - installJavascriptInterface(webView: WebView) for the Android implementation.
SNMobileAnalytics - addEvent(String eventName, Object properties)
Adds a new web-triggered event with its associated properties to the current mobile session timeline.
Name | Type | Description |
---|---|---|
eventName | String | Name of the event to add. |
properties | Object | Optional. List of
custom
property key-value pairs for the event. Supported value types:
Note: The total size of the eventName, properties key and
value should not exceed 300 bytes (per event). |
Type | Description |
---|---|
None |
Example
SNMobileAnalytics - addScreenAction(String actionName)
Adds a new screen UI action tag to the current mobile session time line.
Name | Type | Description |
---|---|---|
actionName | String | Name of the triggered web action. |
Type | Description |
---|---|
None |
Example
SNMobileAnalytics - setUserId(String userId)
Sets the ID of the current active user for the current mobile session.
Name | Type | Description |
---|---|---|
userID | String | ID to set for the current user. |
Type | Description |
---|---|
None |
Example
SNMobileAnalytics - startScreen(String screenName)
Adds a new web-triggered page to the current mobile session time line.
Name | Type | Description |
---|---|---|
screenName | String | Name of the screen to log the start time for, such as WelcomeScreen. |
Type | Description |
---|---|
None |