Basic API Introduction (Unreal Engine)
|
Collect
1. Set user ID
When using the SDK, the SDK uses the device ID as the anonymous ID of each user by default. This ID will be used as the ID of the user when the user is not logged in.
- Android: The SDK uses AndroidId as the device ID by default, and gets a random UUID if AndroidId cannot get it.
- iOS: If the App introduces the AdSupport library, the SDK uses IDFA as the anonymous ID. If IDFV or UUID is used, the device ID changes when the user uninstalls and reinstalls the App. You can also configure IDFA (for example, 1E2DFA89-496A-47FD-9941-DF1FC4E6484A). If IDFA is enabled, the SDK will obtain IDFA first. If IDFA fails to be obtained, the SDK will try to obtain IDFV again. Using IDFA prevents the user from changing the device ID after reinstalling the App.
- macOS:Default useThe unique string associated with the login account of the current computer is passed as an anonymous IDUnreal Engine provided interfaces FPlatformMisc: : GetLoginId () to obtain, if can't get access to random UUID.
- Windows:Default useThe unique string associated with the login account of the current computer is passed as an anonymous IDUnreal Engine provided interfaces FPlatformMisc: : GetLoginId () to obtain, if can't get access to random UUID.
When the user successfully registers or logs in, the SDK needs to be calledLogin method:
USensorsAnalytics::Login("登录 ID");
To accurately record the behavior information of the login user, you are advised to call the user once at each of the following timesLogin method:
- When the user is successfully registered
- When the user logs in successfully
- Every time a logged-in user launches the App
2. Buried point event acquisition
2.1. Set the event public properties
Attributes that need to be added for all events can be passed after initializing the SDKRegisterSuperProperties Register the property as a public property:
USensorsAnalytics::RegisterSuperProperties("{\"GameName\":\"MyGame\"}");
Public properties are saved in the local cache and can be use UnregisterSuperProperty to deletes the specified public property, or uses ClearSuperProperties delete all the public properties of the event that have been set.
2.2. Record activation event
Can call TrackAppInstall method records activation events, and calling this method multiple times will only trigger the activation event on the first call:
USensorsAnalytics::TrackAppInstall("{\"DownloadChannel\":\"AppStore\"}");
Windows & macOS platform on v0.0.3 and later versions are supported TrackAppInstall method
2.3. Code bury trace event
After SDK initialization, you can use Track method tracks user behavior events and adds custom properties to events:
USensorsAnalytics::Track("BuyProduct", "{\"ProductID\":123456,\"ProductCatalog\":\"Laptop Computer\"}");
3. User attribute
- For the difference between event properties and user properties, seeData model
- For naming restrictions on user attributes, seeData format
3.1. 设置用户属性
Set method You can set user attributes. When the same key is set multiple times, the value of the value will be overwritten and replaced.
USensorsAnalytics::Set("{\"Gender\":\"Male\",\"Age\":18}");
3.2. Records the user properties that were set for the first time
We can use properties that are only valid when first set SetOnce to record these properties. Different from Set , If the set user property already exists, the record is ignored without overwriting existing data, and is automatically created if the property does not exist. Therefore,SetOnce This parameter is applicable to setting the first activation time and first registration time. For example:
USensorsAnalytics::SetOnce("{\"AdSource\":\"Email\"}");
3.3. Attributes of a numeric type
For user properties of numeric types, you can use Increment Adds the property values. It is often used to record attributes such as the number of user payments, payment amount, and points. For example:
USensorsAnalytics::Increment("{\"UserPaid\":1}");
3.4. Properties of a list type
For attributes such as the user's favorite movie and the restaurant that the user has reviewed, the column phenotype attributes can be recorded. For example:
USensorsAnalytics::Append("Movies", "[\"Sicario\",\"Love Letter\"]");
3.5. Attribute cancellation
If you need to cancel a user property that has been set, you can call Unset to cancel:
USensorsAnalytics::Unset("Age");
4. Data storage and sending
You need more fine-grained control over your analytics and can set up the data acquisition function with the following options.
4.1. Data acquisition
On every call Track、Login、ProfileSet The SDK will store buried events in the cache and check the following conditions to determine whether to upload data to the server:
- Whether WIFI/2G/3G/4G/5G network conditions(Currently, only Android and iOS devices are supported)
- Whether one of the sending conditions is met:
- If the time interval between the current and the last sending exceeds Flush Interval
- If the number of locally cached logs exceeds Flush Bulk Size
- The event type is Login and triggered by the $SignUp event.
The default Flush Bulk Size is 100, and the default Flush Interval is 15 seconds. When the conditions are met, the Sensing SDK will compress the data with gzip and send it to the Sensing Analysis in batches.
If you pursue the timeliness of data collection, you can call the Flush method to force the data to be sent to Sensing Analysis, for example:
USensorsAnalytics::Flush();
For Android and iOS, when entering the background state, the SDK will call the Flush method to send the cached data to Sensing Analysis.
4.2. Empty the locally cached event
You can delete all locally stored events by using the DeleteAll method.
Unless it's a special requirement, please do not call this method.
USensorsAnalytics::DeleteAll();
Note: The content of this document is a technical document that provides details on how to use the Sensors product and does not include sales terms; the specific content of enterprise procurement products and technical services shall be subject to the commercial procurement contract.