Users
In order to track your authenticated users through their navigation, you can set their identifiers once and our SDKs will automatically send the dedicated properties in each events.
Our SDKs will store these identifiers client-side by default. You can however disable this feature when calling the method.
The first string assigned to the user_id
will be applied to all events within the visit. We recommend leaving it unset if the user is not logged in.
Set user identifiers
- Javascript
- Android (3.3.0+)
- Android
- Apple
- Flutter
Method:
pa.setUser(userId[, userCategory, enableStorage])
Parameters | Type | Description |
---|---|---|
userId | string | User identifier |
userCategory | string | User category |
enableStorage | boolean | Indicates whether the identifiers should be stored (true - default) or not (false ) |
pa.setUser("WEB-192203AJ", "premium", false);
val userStorage = PianoAnalytics.getInstance().userStorage
// set current user
userStorage.currentUser = User("WEB-192203AJ", category = "premium", shouldBeStored = false)
await _pianoAnalytics.setUser(
id: "WEB-192203AJ",
category: "premium",
enableStorage: false
);
Method:
func PianoAnalytics.setUser(id) -> void
func PianoAnalytics.setUser(id,category) -> void
func PianoAnalytics.setUser(id,category,enableStorage) -> void
Parameters | Type | Description |
---|---|---|
id | String | User identifier |
category | String | User category |
enableStorage | Boolean | Indicates whether the identifiers should be stored (true - default) or not (false ) |
pa.setUser("WEB-192203AJ", "premium", false);
Method:
pa.setUser(_ id: String, category: String? = nil, enableStorage: Bool = true)
Parameters | Type | Description |
---|---|---|
id | String | User identifier |
category | String? | User category |
enableStorage | Bool | Indicates whether the identifiers should be stored (true - default) or not (false ) |
pa.setUser("WEB-192203AJ", category: "premium", enableStorage: false);
Retrieve user data
You can retrieve user data thanks to a dedicated method
- Javascript
- Android
- Apple
- Flutter
Method:
pa.getUser(callback)
Parameters | Type | Description |
---|---|---|
callback | function | Callback of the method |
pa.getUser(function (userData) {
console.log("User: " + userData.id + ", Category: " + userData.category);
});
Method:
func PianoAnalytics.getUser(PianoAnalytics.OnGetUserListener) -> void
pa.getUser(user -> {
// do something with user
});
var user = await _pianoAnalytics.getUser();
Method:
pa.getUser(completionHandler: ((_ user: User?) -> Void)?)
pa.getUser { user in
print(user?.id)
print(user?.category)
}
Delete user data
You can delete user data thanks to a dedicated method
- Javascript
- Android
- Apple
- Flutter
Method: pa.deleteUser()
pa.deleteUser();
Method: func PianoAnalytics.deleteUser() -> void
pa.deleteUser();
await _pianoAnalytics.deleteUser();
Method: pa.deleteUser()
pa.deleteUser();