Example app is under example directory, use Android Studio to build and run the app.
Make sure to update serverUrl and token in GIAP.initialize() before running.
Step 1: Add this repository as a submodule
git submodule add https://github.com/tutoruniverse/giap_android.gitStep 2: Import giap_android/giap as a module
- In Adnroid Studio, select
File->New->Import Module... - Choose
giap_android/giap
Step 3: Implement giap in build.gradle
- Open
build.gradleof your app - Add this line
...
dependencies {
...
implementation project(':giap')
...
}
final GIAP giap = GIAP.initialize(
"http://server-url.example",
"your_project_token",
MainActivity.this
);Use this method right after user has just signed up.
giap.alias(userId);Use this method right after user has just logged in.
giap.identify(userId);Use a string to represent the event name and a JSONObject to contain all custom properties.
// With custom props
try {
JSONObject props = new JSONObject();
props.put("price", 100);
props.put("package_sku", "package_1_free");
giap.track("Purchase", props);
} catch (JSONException e) {
e.printStackTrace();
}
// Without custom props
giap.track("End session");At any moment after initializing the lib, you can set custom properties for current tracking profile.
try {
JSONObject props = new JSONObject();
props.put("full_name", "John Doe");
giap.updateProfile(props);
} catch (JSONException e) {
e.printStackTrace();
}Increase/Decrease a numeric property
giap.increaseProperty("count", 1);Append new elements to a list property
JSONArray array = new JSONArray();
array.put("red");
array.put("blue");
giap.appendToProperty("tags", array);Remove elements from a list property
JSONArray array = new JSONArray();
array.put("red");
array.put("blue");
giap.removeFromProperty("tags", array);Use this method right after user has just logged out. It will generate new distinct ID for new visitor.
giap.reset();