Android SDK (client)
Install the Ours Privacy Android SDK to capture privacy-first analytics in Android apps with event tracking and user identification.
The Ours Privacy Android SDK brings privacy-first analytics to your Android applications. It delivers a comprehensive feature set for event tracking, user profiles, and compliance without compromising performance.
- Maven Central package
- GitHub repository: full README, API reference, and release notes
Key features include:
- Event Tracking (
track): Record custom events with optional properties. - User Identification (
identify): Associate events with a specific user ID. - Flush (
flush): Send the queued events immediately instead of waiting for the next batch. - Reset (
reset): Clear the queue and rotate the visitor ID, for example on logout. - Default Properties: Attach event, user, and consent properties to everything the SDK sends.
- Opt In and Opt Out (
optInTracking,optOutTracking): Gate sending on the consent you collected in your own UI. - Deep-link Attribution (
trackDeepLink): Read UTM parameters and ad-platform click IDs off an inbound link. - Setting the Visitor ID (
setVisitorId): Stitch an app user to the profile holding their web history. - Configuration: Project token, ingest URL, automatic lifecycle events, and an opt-out default.
Installation
Add the dependency to your app's build.gradle (use the latest version from Maven Central):
dependencies {
implementation 'com.oursprivacy:oursprivacy-android:<latest>'
}Make sure mavenCentral() is listed in your repositories block.
Required Permissions
Add these permissions to your AndroidManifest.xml:
<!-- Required for sending events -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- Optional but recommended for network state awareness -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Optional for Bluetooth state tracking -->
<uses-permission android:name="android.permission.BLUETOOTH" />Web-to-app Identity
When your app is opened by a link carrying ours_visitor_id, the SDK sets that visitor ID for you, and every event after it lands on the profile that already holds the person's web history and campaign context. The same call reads the UTM parameters and roughly 25 ad-platform click IDs off that link.
Hand the URL over with op.trackDeepLink(url), or pass it as initialURL in the init options and let the SDK parse it at startup. If your app already holds the visitor ID, from a WebView or a native bridge, set it directly with op.setVisitorId("550e8400-e29b-41d4-a716-446655440000").
Forward the opening URL. The SDK hooks nothing in the operating system, so your activity has to hand over the URL it was opened with, on first launch and while the app is already running:
// MainActivity
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
intent?.data?.let { op.trackDeepLink(it.toString()) }
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
intent.data?.let { op.trackDeepLink(it.toString()) }
}Your activity also needs an <intent-filter> in AndroidManifest.xml with the VIEW action and the BROWSABLE category, or Android never delivers the link to your app at all:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="links.example.com" />
</intent-filter>On Android, parsed UTM parameters and click IDs survive a full app restart. Attribution holds either way, because the join happens on the visitor ID rather than on the campaign parameters.
Mobile app attribution covers how app attribution works end to end, and when you need a mobile measurement partner alongside it.
Read More
For the full API, setup options, and release notes, see the Android SDK README on GitHub.
Compatibility
- Android API 21+ (Android 5.0 Lollipop and above)
- Kotlin 1.5+
- Gradle 7.0+
Explore the API
Want to see what you can send? Try our playground for a point-and-click payload builder to explore what you can send.
Getting Help
For support or questions, contact support@oursprivacy.com.
Next Steps
- Client SDKs overview - pick the right SDK for each surface.
- iOS SDK - for the native iOS counterpart.
- React Native SDK - if you are shipping a cross-platform mobile app.
- Mobile app attribution - how app attribution works, and when you need a mobile measurement partner.
How is this guide?

