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 |
sdk_switch_role | OEGEvents.SWITCH_ROLE | OEGAuth.setGameRole() replaces an already-active role with a different server/role — see Game Role API |
sdk_logout_game_role | OEGEvents.LOGOUT_GAME_ROLE | OEGAuth.logoutGameRole() clears an active role — see Game Role API |
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 (server_id, role_id, server_name, role_name,
role_level) to the auto-tracked lifecycle events above. See
Game Role API for the full call contract, logoutGameRole(), and
the sdk_switch_role/sdk_logout_game_role events it fires.
Role fields are attached to the six auto-tracked events listed above only —
OEGAnalytics.logEvent() / logRevenue() calls are not enriched automatically;
pass any server/role context you need on those explicitly via parameters.
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.