Custom Analytics
User Analytics#
By default, users' log data are automatically stored via login and payment functionality of the Nbase SDK. With the logEvent
function, it's also possible to export the log data only without the login and payment functionality integrated.
Warning
If you are already using login and payment feature, the logEvent function is not required, as the log data are handled by those features automatically. Please follow the guide below only if you are using your own login and payment functionality but wish to store logs for analytics.
Installation#
No separate installation required. With the basic SDK installed, use the logEvent
function to export the event data.
Getting started#
userId
must be entered for logs to be stored correctly.
_10NBase.setMemberId("userId");
Send events after login#
_10NBase.trackEvent("loginlogs", (status, error) -> {_10});
Send events after sign-up#
_10var loginParam = new NBaseSDK.NBase.TrackingParameter(status: true, serverId: "server#1");_10 NBaseSDK.NBase.trackEvent("joins", loginParam, (status, error) => {_10 if (error != null)_10 {_10 Debug.Log(error.Message.ToString());_10 return;_10 }_10 });
Send events after payment#
_19var purchaseParam = new NBaseSDK.NBase.TrackingParameter(_19 status: true,_19 productId: "P12345", // product ID_19 paymentId: "google", // google, apple, amazon, one ..._19 orderId: "Ord1234",_19 currency: "USD",_19 price: 9.99,_19 serverId: "Server1"_19);_19_19 NBaseSDK.NBase.trackEvent("purchases", purchaseParam, (status, error) => {_19 Debug.Log("[Unity] trackEvent...ok " + status);_19 if (error != null)_19 {_19 NBaseSDK.NBase.showToast(error.Message.ToString());_19 return;_19 }_19 NBaseSDK.NBase.showToast(status.ToString());_19});
Name | Type | Description | Required |
---|---|---|---|
productId | string | Product ID | Y |
paymentId | string | google, apple, amazon, one | Y |
orderId | string | Order ID of the transaction | Y |
currency | string | Currency | Y |
price | double | Purhcase price | Y |
serverId | string | Server ID | N |
- SDK utilizes useful information, such as operating system and app version, to automatically send event data.
- Logs that are automatically sent can be managed manually. This specific SDK does not track events automatically, requiring the
trackEvent
to be called. Therefore, it is recommended to run thetrackEvent
after the application launched. - The
trackEvent
function does not run in the background. - Only strings and integers are allowed on the user definition fields.