Tracking in Android Applications

This guide shows how to integrate Roivenue Tracking in an Android app using Kotlin. It sends lightweight JSON events (pageview, conversion) with device and session UTM data.

Prerequisites

Android Studio Hedgehog (2024+)

Kotlin 1.9+

Min SDK 24+

Internet permission in AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET"/>

What the Tracking API Expects

The Roivenue endpoint accepts events in JSON format. Each event represents a user interaction and includes basic context (timestamp, device info, URL, etc.) plus optional conversion data.

{
  "propertyId": "adbfb3aa-xxxx-xxxx-xxxx-xxxxxxxx",
  "type": "pageview",
  "timestamp": "2024-10-30T07:50:40",
  "url": "https://example.com/?utm_source=facebook",
  "deviceId": "20904e-f1e3-79f2-b5b7-00d6a7bfe57e",
  "userId": "someUserHashed",
  "referer": "$direct",
  "screenWidth": 1170,
  "screenHeight": 2532,
  "utmSource": "facebook",
  "utmMedium": "cpc",
  "utmCampaign": "autumn_sale",
  "conversionType": "purchase",
  "conversionId": "ORD-001",
  "conversionValue": 149.99,
  "currencyCode": "EUR"
}

Capturing and Managing UTMs

UTMs describe the source of the current session. They are cleared on app cold start and refreshed when the app is opened via a new deep link.

DeviceId generation

Generate a device ID compliant with Google Play and App Tracking Transparency rules.

RoivenueTracker.kt

Tracking Page Views

Tracking Conversions

Last updated

Was this helpful?