Web Analytics
Adjust and GA4/Firebase tracking are configured automatically via the Alogame backend
(/v2/config). No local setup required in the SDK — the game never hard-codes an
app token, event token, or Measurement ID.
Event names, their Adjust tokens, and the GA4 whitelist/Measurement ID are managed by your game operator on the backend — you do not configure them in the game. As a developer you only call the logging APIs below with the event name agreed with your operator.
Adjust and GA4 are wired up independently. A game can have one, both, or neither
enabled — a platform with no config (missing adjust_app_token / no
firebase_measurement_id) is simply inert (no-op), and never affects the other
platform.
Auto-tracked events
The SDK automatically tracks the following lifecycle events when configured on the backend — no game code required:
| Event Name | Constant (OEGEvents) | Trigger |
|---|---|---|
sdk_show_login | OEGEvents.SHOW_LOGIN | The built-in login UI is shown (OEGWebSdk.openLogin()) |
sdk_register_success | OEGEvents.REGISTER_SUCCESS | Registration completed (including a guest session and a first-time social login) |
sdk_login_success | OEGEvents.LOGIN_SUCCESS | Regular, guest, or social login completed |
sdk_logout | OEGEvents.LOGOUT | Explicit OEGAuth.logout() while a session was active |
import { OEGEvents } from '@alogame/web-sdk';
console.log(OEGEvents.LOGIN_SUCCESS); // 'sdk_login_success'
Unlike the native SDKs, the web SDK has no in-app purchase flow (sdk_recharge
is not auto-tracked on web) — top-ups go through the external payment portal (see
Floating Button). If your operator wants recharge data from web, log
it yourself with logRevenue below.
Set Game Role
If your game has servers/characters, call
OEGAuth.setGameRole() after login
so the SDK can attach role context to every auto-tracked (and future) analytics
event — without it, events carry no server/role info:
import { OEGAuth } from '@alogame/web-sdk';
await OEGAuth.setGameRole(
'server-01', // serverId
'role-12345', // roleId
'Asia 1', // serverName (optional)
'DragonSlayer', // roleName (optional)
42 // level (optional)
);
setGameRole param | Analytics parameter |
|---|---|
serverId | server_id |
roleId | role_id |
serverName | server_name |
roleName | role_name |
level | role_level |
Once set, these fields are attached automatically to every subsequent
OEGAnalytics.logEvent / logRevenue call and every auto-tracked event
(sdk_login_success, sdk_logout, …) — not just the four lifecycle events.
The role is persisted (survives a page reload) and only needs to be set once per
session, but is cleared on OEGAuth.logout() so it never leaks into the next
account's events.
Fields are attached from whatever role is currently stored at the moment an event
fires. Call setGameRole() as soon as the player's server/character is known —
events logged before that point simply go out without server_id/role_id.
Log a custom event
An event is just a name plus optional string parameters — there's no fixed list. Which names exist, and how each maps to an Adjust event token, is defined by your operator; the SDK resolves the name to a token at runtime. An event whose name has no token configured (Adjust) or isn't in the whitelist (GA4) is silently skipped, not an error.
import { OEGAnalytics } from '@alogame/web-sdk';
OEGAnalytics.logEvent('tutorial_complete');
OEGAnalytics.logEvent('level_up', { level: '10', score: '15000' });
Log a revenue event
Events that carry money — Recharge, first_recharge, or any custom revenue
event — must use logRevenue so Adjust/GA4 record the actual amount.
Sending the amount only as a plain string parameter is not counted as revenue.
import { OEGAnalytics } from '@alogame/web-sdk';
OEGAnalytics.logRevenue('Recharge', {
revenue: 99000, // real amount paid, must be > 0
currency: 'VND', // ISO 4217
orderId: 'order_12345', // dedup id (Adjust deduplicationId)
parameters: { payment_channel: 'web_store', product_id: 'vip_pack_1' },
});
The event must be set up as a revenue event by your operator on the Adjust side.
Enable / disable tracking
import { OEGAnalytics } from '@alogame/web-sdk';
OEGAnalytics.setTrackingEnabled(false); // opt out — persisted across reloads
OEGAnalytics.setTrackingEnabled(true);
OEGAnalytics.isTrackingEnabled(); // boolean, false before the SDK is initialized
Backend configuration
Onboarding a new app (Adjust app token, per-event tokens, GA4 Measurement ID,
event whitelist) is a backend/CMS task, not a client change — ask your Alogame
operator for the /v2/config data.tracking contract. The game code above never
changes when moving between apps/environments; only gameId at init() does.