Skip to main content

Android Analytics

Adjust tracking is configured automatically via the Alogame backend. No local setup required in the SDK.

Event names, their Adjust tokens, and the Adjust app token are managed by your game operator on the backend — you do not configure them in the app. As a developer you only call the logging APIs below with the event name agreed with your operator.

Auto-Tracked Events

The SDK automatically tracks the following lifecycle events when configured in the backend:

Event NameDescriptionTrigger
sdk_show_loginLogin screen displayedUser opens login UI
sdk_register_successRegistration completedUser successfully registers
sdk_login_successLogin completedUser successfully logs in (manual login only)
sdk_logoutUser logged outUser logs out or session expires
sdk_rechargeIn-app purchase completedIAP verification succeeds

These events are tracked automatically once your operator has set them up on the backend. No game code required.

Set Game Role

To enable role-specific tracking data (used in sdk_recharge and other events), call setGameRole() after the player enters the game:

Kotlin
import vn.oeg.sdk.v2.core.auth.OEGAuthCore

OEGAuthCore.setGameRole(
serverId = "server_01",
serverName = "Server 1", // optional
roleId = "character_123",
roleName = "DragonSlayer", // optional
level = 50 // optional
)
Java
import vn.oeg.sdk.v2.core.auth.OEGAuthCore;

// serverId, serverName (null = omit), roleId, roleName (null = omit), level (0 = default)
OEGAuthCore.INSTANCE.setGameRole("server_01", "Server 1", "character_123", "DragonSlayer", 50);

This information is used to enrich tracking events with player context. The SDK automatically clears this data on logout.

See also: Game Role API for detailed documentation and usage examples.

Log an event

The SDK can log any event — there is no fixed list. An event is just a name plus optional string parameters. Which events exist, and how each name maps to an Adjust event token, is defined by your game operator (in Adjust + the Alogame backend); the SDK resolves the name to a token at runtime. You only need the event name agreed with your operator.

An event whose name has no token configured is silently skipped (no tracking, no error).

Kotlin
import vn.oeg.sdk.v2.core.analytics.OEGAnalytics

OEGAnalytics.logEvent("tutorial_complete")

OEGAnalytics.logEvent("level_up", mapOf(
"level" to "10",
"score" to "15000"
))
Java
import vn.oeg.sdk.v2.core.analytics.OEGAnalytics;
import java.util.HashMap;
import java.util.Map;

OEGAnalytics.INSTANCE.logEvent("tutorial_complete");

Map<String, String> params = new HashMap<>();
params.put("level", "10");
params.put("score", "15000");
OEGAnalytics.INSTANCE.logEvent("level_up", params);

Log a revenue event

Events that carry money — Recharge (web_store / WebPay top-ups), first_recharge, or any custom revenue event — must set the real Adjust revenue with logRevenue. Sending the amount only as a plain parameter (e.g. charged_value) is not counted by Adjust — the dashboard would show 0.

Native IAP is automatic

The native Google Play IAP flow fires sdk_recharge with revenue already set — no game code needed. Use logRevenue only for events the game pushes itself (web_store / WebPay recharges and custom revenue events).

The revenue is attached to the event's own token, so that event must be set up as a revenue event by your game operator. orderId deduplicates against double-counting.

Kotlin
import vn.oeg.sdk.v2.core.analytics.OEGAnalytics

OEGAnalytics.logRevenue(
"Recharge", // event name set up as a revenue event by your operator
revenue = 99000.0, // real amount paid (must be > 0)
currency = "VND", // ISO 4217
orderId = "order_12345", // dedup id
parameters = mapOf("payment_channel" to "web_store", "product_id" to "vip_pack_1")
)
Java
import vn.oeg.sdk.v2.core.analytics.OEGAnalytics;
import java.util.HashMap;
import java.util.Map;

Map<String, String> params = new HashMap<>();
params.put("payment_channel", "web_store");
params.put("product_id", "vip_pack_1");

// logRevenue(eventNameOrToken, revenue, currency, orderId, parameters)
OEGAnalytics.INSTANCE.logRevenue("Recharge", 99000.0, "VND", "order_12345", params);

A recharge is a revenue event — always send it via logRevenue, not the plain logEvent, otherwise Adjust records no revenue.

Enable / disable tracking

Kotlin
OEGAnalytics.setTrackingEnabled(false)
OEGAnalytics.setTrackingEnabled(true)
Java
OEGAnalytics.INSTANCE.setTrackingEnabled(false);
OEGAnalytics.INSTANCE.setTrackingEnabled(true);

Uninstall Tracking

Uninstall tracking is automatic — no game code required. When the FCM token is obtained or rotated, the SDK forwards it to Adjust. Adjust then periodically sends a silent push to each device; if delivery fails, the device is counted as an uninstall.

Requirements:

  • FCM must be configured (see Push Notifications)
  • OEGNotificationService declared in AndroidManifest.xml
  • Adjust app token configured by your operator

To attribute re-engagement campaigns (user taps an Adjust link while the app is already installed), call OEGAnalytics.processDeeplink() from your main Activity. Install attribution works regardless — this is only needed to credit campaigns that bring back existing users.

Kotlin
import android.content.Intent
import vn.oeg.sdk.v2.core.analytics.OEGAnalytics

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
intent?.data?.let { OEGAnalytics.processDeeplink(it, this) }
}

override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
intent.data?.let { OEGAnalytics.processDeeplink(it, this) }
}
}
Java
import android.content.Intent;
import vn.oeg.sdk.v2.core.analytics.OEGAnalytics;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getIntent() != null && getIntent().getData() != null) {
OEGAnalytics.INSTANCE.processDeeplink(getIntent().getData(), this);
}
}

@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (intent != null && intent.getData() != null) {
OEGAnalytics.INSTANCE.processDeeplink(intent.getData(), this);
}
}

Lifecycle

Call in your main game Activity:

Kotlin
override fun onResume() {
super.onResume()
OEGAnalytics.onResume()
}

override fun onPause() {
super.onPause()
OEGAnalytics.onPause()
}
Java
@Override
public void onResume() {
super.onResume();
OEGAnalytics.INSTANCE.onResume();
}

@Override
public void onPause() {
super.onPause();
OEGAnalytics.INSTANCE.onPause();
}