Attributes are collected by default by the Luciq SDK. These attributes contain information related to the users. You can add custom attributes using these APIs. Attributes can be added, retrieved, and removed.
Adding
Attach custom attributes to your user by passing two strings to the set attribute API. Much like a dictionary or map, the two strings are the value and key of the attribute.
Adding Attributes
Luciq.setUserAttribute("True", withKey: "Logged in")
Luciq.setUserAttribute("False", withKey: "Completed IAP")
[Luciq setUserAttribute:@"True" withKey:@"Logged in"];
[Luciq setUserAttribute:@"18" withKey:@"Age"];
Luciq.setUserAttribute("Age", "18");
Luciq.setUserAttribute("LoggedIn", "True");
Luciq.setUserAttribute("Age", "18")
Luciq.setUserAttribute("LoggedIn", "True")
Luciq.setUserAttribute("Age", "18");
Luciq.setUserAttribute("Logged", "True");
Luciq.setUserAttributeWithKey(String value, String key)
//Examples
Luciq.setUserAttributeWithKey("18", "Age");
Luciq.setUserAttributeWithKey("True", "Logged In");
Luciq.setUserAttribute('Logged_out', 'true');
//iOS
Luciq.SetUserAttribute("18", "Age");
Luciq.SetUserAttribute("True", "LoggedIn");
//Android
Luciq.SetUserAttribute("Age", "18");
Luciq.SetUserAttribute("LoggedIn", "True");
Retrieving
You can retrieve all attributes related to a user using the retrieve API. This API returns an NSDictionary
for iOS and a HashMap
for Android.
Retrieving Attributes
//Retrieving
let loggedIn = Luciq.userAttribute(forKey: "Logged in")
//Retrieve all
let allUserAttributes = Luciq.userAttributes()
//Retrieve one
NSString *loggedIn = [Luciq userAttributeForKey:@"Logged in"];
//Retrieve all
NSDictionary *allUserAttributes = [Luciq userAttributes];
//Get map of all user attributes
HashMap<String, String> userAttrs = Luciq.getAllUserAttributes();
//Get map of all user attributes
val userAttrs = Luciq.getAllUserAttributes()
// Getting attribute
Luciq.getUserAttribute("Logged in", function(attribute) {
// `attribute` is the return value
});
// Loading all attributes
Luciq.getAllUserAttributes(function (allAttributes) {
// `allAttributes` Object containing all keys and attributes
});
// Getting attribute
Luciq.getUserAttributeForKey("Logged in");
// Loading all attributes
Luciq.getUserAttributes();
Luciq.getUserAttribute(
'Logged_out',
function (userAttribute) {
console.log('Logged out: ' + userAttribute);
},
function (error) {
console.log(error);
}
);
Luciq.getAllUserAttributes(
function (userAttributes) {
console.log('Keys: ' + Object.keys(userAttributes));
console.log('Logged out: ' + userAttributes.Logged_out);
},
function (error) {
console.log(error);
}
);
//iOS
//Get all the created user attributes
Luciq.UserAttributes();
//Get the value of a ceratin user attribute
Luciq.UserAttributeForKey("Age");
//Android
//Get the value of a ceratin user attribute
String value = Luciq.GetUserAttribute("Age");
Removing
Attributes can be removed from a user by passing the key of the attribute you'd like to remove to the removal API.
Removing Attributes
Luciq.removeUserAttribute(forKey: "Logged in")
[Luciq removeUserAttributeForKey:@"Logged in"];
//remove a user attribute
Luciq.removeUserAttribute("KEY");
//remove all user attributes
Luciq.clearAllUserAttributes();
//remove a user attribute
Luciq.removeUserAttribute("KEY")
//remove all user attributes
Luciq.clearAllUserAttributes()
Luciq.removeUserAttribute("Completed IAP");
Luciq.removeUserAttributeForKey("Logged In");
Luciq.removeUserAttribute('Logged_out');
//iOS
//Remove a user attribute
Luciq.RemoveUserAttributeForKey("Age");
//Android
//Remove a user attribute
Luciq.RemoveUserAttribute("Age");
//Remote all user attributes
Luciq.ClearAllUserAttributes();