To declare the mavenCentral() repository. Add mavenCentral() in the project-level build.gradle.
allprojects {
repositories {
...
mavenCentral()
...
}
}
Or in the app module's build.gradle
repositories {
...
mavenCentral()
...
}
Then add dependencies to app/build.gradle
implementation 'com.appier:woopra-android:1.1.1'
To setup your tracker SDK, configure the tracker instance as follows (replace mybusiness.com
with your domain name):
// Java
WoopraTracker tracker = Woopra.getInstance(this /* context (e.g. activity) */).getTracker("mybusiness.com");
// Kotlin
val tracker = Woopra.getInstance(this /* context (e.g. activity) */).getTracker("mybusiness.com")
To track an event, you must setup a WoopraEvent
object and track it:
// Java
// setup event
WoopraEvent event = new WoopraEvent("app_viewed");
event.setProperty("view", "home screen");
event.setProperty("title", "Home Screen");
event.setProperty("property_boolean", true);
// track event
tracker.trackEvent(event);
// Kotlin
// setup event
val event = WoopraEvent("app_viewed")
event.setProperty("view", "home screen")
event.setProperty("title", "Home Screen")
event.setProperty("property_boolean", true)
// track event
tracker.trackEvent(event)
To add custom visitor properties, you should edit the visitor object:
// Java
tracker.setVisitorProperty("name", "John Smith");
tracker.setVisitorProperty("email", "[email protected]");
// Kotlin
tracker.setVisitorProperty("name", "John Smith")
tracker.setVisitorProperty("email", "[email protected]")
You can then send an identify call without tracking an event by using the tracker.push()
method:
// Java
tracker.push();
// Kotlin
tracker.push()
To add referrer information, timestamp, and other track request properties, look at the WoopraTracker
and WoopraEvent
class public methods for an exhaustive list of setter methods. Here are some common examples:
// Java
tracker.setReferer(<REFERRER_STRING>);
// Kotlin
tracker.referer = <REFERRER_STRING>
Note
For legacy of this SDK as well as the HTTP, you can use both referer
or referrer
methods, but it will be stored as referer
.
You can update your idle timeout (default: 5 minutes) by updating the timeout property in your Woopra tracker:
// Java
tracker.setIdleTimeout(300);
// Kotlin
tracker.idleTimeout = 300
Note
The idle timeout is in seconds.
You can explicitly set a timestamp for an event:
// Java
event.setTimestamp(<LONG_UNIX_MS_TIMESTAMP>);
// Kotlin
event.timestamp = <LONG_UNIX_MS_TIMESTAMP>
Note
The unix epoch time is in milliseconds.
Except as otherwise noted, the Woopra Android SDK is licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0.html).
Ruby on Rails is released under the MIT License