Overview
This document describes the Pendo android SDK Public APIs.
Pendo Class Public APIs
Modifier and return value |
API Public method (Java) |
Description |
---|---|---|
static synchronized void |
initSDK(Application app, String appKey, PendoInitParams params) |
Initializes the Pendo SDK from an Application class using the specified app key and params. |
static synchronized void |
initSDK(Activity activity, String appKey, PendoInitParams params) |
Initializes the Pendo SDK from an Activity class using the specified app key and params. |
static synchronized void |
initSdkWithoutVisitor(Application app, String appKey, PendoOptions options, PendoPhasesCallbackInterface calllbacks) |
Initializes the Pendo SDK without visitor and account data, using the specified app key and options, in the specified application context. Options should always be null, initialization phases are denoted by the callbacks interface.
|
static void |
switchVisitor(String visitorId, String accountId, Map<String, Object> visitorData, Map<String, Object> accountData) |
Ends the current session when there is an active session then starts a new session with the new visitor and account information. Passing null as the visitorId will generate an anonymous visitor id. Must be called after the SDK was initialized. |
static void |
endSession() |
Ends the active session and stops collecting analytics or show guides to the user. More details here. Must be called after the SDK was initialized. |
static void |
clearVisitor() |
Ends the active session starts a new session with an anonymous visitor. Must be called after the SDK was initialized. |
static void |
setVisitorData(Map<String, Object> visitorData) |
Update the visitor metadata. Must be called after the SDK was initialized. |
static void |
setAccountData(Map<String, Object> accountData) |
Update the account metadata Must be called after the SDK was initialized. |
String |
getVisitorId() |
Returns the ID of the visitor in the active session. |
String |
getAccountId() |
Returns the ID for the account in the active session. |
static void |
setAccountId(String accountId) |
Sets the ID of the account for the active session. |
static void |
track(String eventName, @Nullable Map<String, Object> properties) |
Sends a track event with the specified properties. Must be called after the SDK was initialized. |
static void |
dismissVisibleGuides() |
Dismisses all visible guide. |
static synchronized void |
pauseGuides(boolean dismissGuides) |
Pauses any guides from showing during an active session. If dismissGuides is TRUE then all visible guides will be dismissed. Must be called after the SDK was initialized. |
static synchronized void |
resumeGuides() |
Resumes showing guides during the active session. Should only be used after pauseGuides. Must be called after the SDK was initialized. |
String |
getDeviceId() |
Returns the device's unique Pendo-generated id. The device id is used by Pendo to generate a unique id for each anonymous visitor. This id is unique per application. |
Pendo Class: PendoInitParams
The following class is used in InitSDK() methods. It includes details about the visitor and the account that can later be used for segmentation and analysis within Pendo.
Make sure to send to Pendo only user and account details that are allowed by your security team and that are not considered private information. Pendo will not share these details with any 3rd party.
Modifier type and return type | Public API method | Description |
N/A |
PendoInitParams() |
Constructor |
PendoInitParams (this) |
setVisitorId(String visitorId) |
Sets the Visitor ID for the session that will start following the initialization with this PendoInitParams object. Null value is used for anonymous visitor |
PendoInitParams (this) |
setVisitorData(Map<String, Object> visitorData) |
Sets the Visitor metadata for the session that will start following the initialization with this PendoInitParams object. |
PendoInitParams (this) |
setAccountId(String accountId) |
Sets the Account ID for the session that will start following the initialization with this PendoInitParams object. |
PendoInitParams (this) |
setAccountData(Map<String, Object> accountData) |
Sets the account's metadata for the session that will start following the initialization with this PendoInitParams object. |
PendoInitParams (this) |
SetCallbackInterface() |
Sets the PendoPhasesCallbackInterface to be called |
Pendo Initialization Guidelines
initSDK
orinitSdkWithoutVisitor
should only be called once during the application lifecycle (select one of the two options).initSDK
andswitchVisitor
have similar functionalities that initiate multiple backend calls and guide retrieval. These APIs should never be called sequentially.initSDK
andswitchVisitor
may take time to complete, depending on network connectivity. CallbackInterface should be used to receive notifications when Pendo SDK initialization completes.switchVisitor
should only be used to switch a visitorID and/or AccountID. No action will be taken if Visitor and Account ID did not change.- clearVIsitor or endSession API should be used when a user logs out of their application use
Initialization when Visitor is known on Application class OnCreate()
When the visitor (identified or anonymous) is known during Application class onCreate
use the initSDK
API. Add the following code in the Application onCreate() method :
Identified visitor
Kotlin
val visitorId = "John Smith"
val accountId = "Acme Inc"
//set visitor metadata
val visitorData: MutableMap<String, Any> = HashMap()
visitorData["age"] = 27
visitorData["country"] = "USA"
//set account metadata
val accountData: MutableMap<String, Any> = HashMap()
accountData["Tier"] = 1
accountData["Type"] = "Enterprise"
val pendoParams = Pendo.PendoInitParams()
pendoParams.visitorId = visitorId
pendoParams.accountId = accountId
pendoParams.visitorData = visitorData
pendoParams.accountData = accountData
Java
Pendo.PendoInitParams pendoParams = new Pendo.PendoInitParams();
pendoParams.setVisitorId("John Smith");
pendoParams.setAccountId("Acme Inc");
//set visitor metadata
Map<String, Object> visitorData = new HashMap<>();
visitorData.put("age", 27);
visitorData.put("country", "USA");
pendoParams.setUserData(visitorData);
//set account metadata
Map<String, Object> accountData = new HashMap<>();
accountData.put("Tier", 1);
accountData.put("Type", "Enterprise");
pendoParams.setAccountData(accountData)
Anonymous visitor
Kotlin
val pendoParams: Pendo.PendoInitParams? = null
Java
Pendo.PendoInitParams pendoParams = null;
Initialize the SDK
Kotlin
Pendo.initSDK(
this,
"YOUR_API_KEY",
pendoParams
)
Java
String pendoAppKey = "YOUR_API_KEY";
Pendo.initSDK(
this,
pendoAppKey,
pendoParams);
Initialization when Visitor is known during Activity Class onCreate()
When a visitor (identified or anonymous) is known later in the application lifecycle, during an Activity class onCreate() (e.g. the user has to login, or has been switched, etc.).
Add the following code in the Application onCreate() method :
Pendo.switchVisitor(
visitorId,
accountId,
visitorData,
accountData
)
Pendo.switchVisitor(
visitorId,
accountId,
visitorData,
accountData);
Track Events Flow
This method allows you to pass track event information using the Pendo SDK.
Use Case Example: Since Pendo already tracks click events (RAClick events) and screen changes (RAScreenView events), a good example would be a callback you would like to track (i.e. transaction response callbacks, such as payment completed or failed, etc.).