See the Overview for details about setting up the Datacoral Collect Events Slice.
Step 1. Add Snowplow to your dependencies
- Download the Snowplow jar file
- Copy the snowplow.jar file into the libs directory of your app.
- Add libs/snowplow.jar and com.squareup.okhttp:okhttp:2.1.0 as project dependencies. If you are using gradle, specify it in build.gradle file as...
- Sync project (if you are using Android Studio)
Step 2: Update Permissions
To send the events, you need to update your AndroidManifest.xml with the internet access permission:
Step 3: Initialize Tracker
- Initialize the Emitter with appropriate values for collector after substituting the appropriate environment parameters.
URL_ENDPOINT : The URL of your Datacoral Events API gateway. Ex. events.dccustomer.datacoral.io
API_KEY : The Datacoral API key to authorize the events invocations. Ex. 1js9q5Gqmk2VDv2omx2WI3yUGV0K7b464fWUJXDX
ENVIRONMENT : Set the environment as
prod, based on the emitter of the events
NAMESPACE : The name of this Tracker instance to include with events sent to the collector. The namespace argument attached to every event fired by the new tracker. This allows you to later identify which tracker fired which event if you have multiple trackers running. Ex. landing_pages
APP_ID : Name of application to include with events sent to the collector. The application ID is used to distinguish different applications that are being tracked by the same Snowplow stack. Ex. "finance" or "hr"
- Import the Android Tracker's classes into your Android code
- Initialize the Tracker with appropriate values for namespace and appId.
Step 4: Track events
To track specific events, invoke the track(event) methods with appropriate event type.