Studio GuideWorld SDK Guide
Log In
World SDK Guide

ZEPETO Analytics

ZEPETO Analytics is a package that makes statistical APIs easy to use.

Currently, Google Analytics is available.

👍

Google Analytics v4 specification is supported


STEP 1 : Install

Window → Package Manager → Please install ZEPETO.World Package 1.21.14 version first.

After that, install the ZEPETO Analytics package.


STEP 2 : Creating Google Analytics Data Streams

📘

Google Analytics

https://analytics.google.com/

After you create your Google Analytics account, you must create a data stream to use in the World. (On average, it takes 1 day to activate the initial account.)

It is recommended that you create and manage one data stream per WorldId.

ZEPETO Analytics sends data using httpService, so please make sure to select the 'web' platform.


Please write the WorldId on where you write the URL.


When the data stream creation is complete, you can verify the Measurement ID.


To generate API Key values, you must enter the Measurement Protocol API secrets menu.


After pressing the Create button on the right, complete the Nickname entry to generate the Secret Value.


Please copy the Measurement ID and Secret Value values for the next process.


STEP 3 : How to Use

In the Hierarchy window, click the ZEPETO → Zepeto Analytics tab.

377

An object called Zepeto Analytics is automatically created as follows:

ZepetoAnalyticsComponent is the component responsible for sending statistics within a Scene.

In the Inspector window, you can enter the settings required to send statistics.


Please select Google Analytics as the Analytics Type and enter Api key and Measurement id.

423

When you play the Scene with the ZEPETO Analytics component added, the cumulative residence time values are automatically accumulated in Google Analytics.

You can view the engagement time value from the Reports > Realtime overview menu. (Report items excluding the Realtime tab take a certain amount of time to be reflected.)

If the scene is changed and the component is deleted, the statistics will not be sent. So if you want to keep it, please process as Don't Destroy.

❗️

Caution

If you check debug mode during the editor test, the data will not be sent to the dashboard.
When you want to stack data, make sure that the debug mode is turned off.


Adding Custom Event

You can stack statistics based on custom events.

Below is an example code that sends a custom event to the Google Analytics dashboard when you press a button.

import { ZepetoScriptBehaviour } from 'ZEPETO.Script';
import { AnalyticsType, ZepetoAnalyticsComponent } from 'ZEPETO.Analytics';
import { Button } from 'UnityEngine.UI';

export default class CustomEvent extends ZepetoScriptBehaviour {

    public zepetoAnalytics: ZepetoAnalyticsComponent;
    public myButton: Button;

    Start() {
        this.myButton.onClick.AddListener(() => {

            // When the button is clicked, a random event is fired to Google Analytics
            const ga = this.zepetoAnalytics.Analytics(AnalyticsType.GoogleAnalytics);

            interface CustomEvent {
                param_01 : string;
                param_02 : number;
            }

            const _event : CustomEvent = {
                param_01 : "param_string_val_01",
                param_02 : 3,
            }
            ga.LogEvent<CustomEvent>("custom_sub_param", _event);
        });
    }
}

Make sure to connect the Zepeto Analytics components after writing the script.

The screenshot below is an example of a component configured to make the example script work.

536

From the Reports > Realtime overview menu, you can see that values for custom events are stacked in real time.

2880

Enable Debug Mode

Google Analytics validates the Payload Body for the CustomEvent you send. (If not valid, will not be sent)

Checking debug mode makes it easy to see the validation results for Payload that you send in the console window.

❗️

Caution

If you check debug mode during the editor test, the data will not be sent to the dashboard.
When you want to stack data, make sure that the debug mode is turned off.

536

If you create a custom event that does not fit your Google specification, validation will fail in debug mode.

657

For information on Google Specifications and Debug Mode, please visit:

📘

For information on Google Specifications and Debug Mode, please visit:


ZepetoBaseAnalytics API

FunctionsDescription
LogEventAllows you to send custom events to the linked Google Analytics dashboard.

Supports single parameters (string, number, boolean) and generic Payload.

For Payload in generic format, only the forms that Google Analytics allows can be transferred.

https://developers.google.com/analytics/devguides/collection/protocol/ga4/validating-events?client_type=gtag
SetAnalyticsCollectionEnabledEnables/disables the Event transmission function of the ZEPETO Analytics Component. Can be used for dynamic control.

By default, the Analytics Component becomes True when Enabled, and False when Disabled.

(Basic residence time is automatically recorded from the time ZEPETO Analytics Component is enabled.)
SendDurationFor a particular Event name, you can transfer the residence time in milliseconds (ms).

Can be used to manually record Engagement Time for a specific event. (Independent of the automatically measured residence time.)

ex) Used to manually record 'I was in a specific area for 3 seconds (3000 ms)'
SetUserPropertyFor the event you are sending, you can add a Custom User property.

https://developers.google.com/analytics/devguides/collection/protocol/ga4/user-properties?hl=en&client_type=gtag
SetUserIDFor the Event you are sending, you can set the UserID for Google Analytics to distinguish. Subsequent data is collected separately in the User section of the Google Analytics dashboard.

https://support.google.com/analytics/answer/9213390

By default, each user is automatically collected by mapping to (GA4) Session units in ZEPETO UserId units.