Important: As of August 13, 2024, this page will no longer be actively maintained. Please refer to the current version of this content here.
If you’re integrating with a Maven project, just add the following dependency to your pom.xml file:
<dependency> <groupId>com.indicative.client.java</groupId> <artifactId>indicative-java</artifactId> <version>1.0.3</version> </dependency>
To start tracking events, first call the apiKey() method and pass in your API key, like so:
Indicative.apiKey("Your-API-Key-Goes-Here");You should only have to do that once. Alternatively, you can hardcode the value of API_KEY at the top of the file. Once your API key is set, you can record events with a single line of code:
Indicative.event("Registration").uniqueId("user47") .addProperty("Gender","Female").addProperty("Age", 23) .done();
Next, the uniqueId() method takes one String argument, which is the unique identifier associated with the user performing the action.
The addProperty() method takes two String arguments for the name and value of the property, respectively. This method is overloaded so that you can pass in int, long, float, double, and boolean property values without having to convert them to Strings yourself.
Finally, you must call done() to asynchronously post the event to our REST endpoint.
This client also includes several unit tests in the IndicativeTest.java file (located in /src/test/java/com/indicative/client/java).