docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Interface IAnalyticsService

    Namespace: Unity.Services.Analytics
    Assembly: solution.dll
    Syntax
    public interface IAnalyticsService

    Properties

    Name Description
    PrivacyUrl

    This is the URL for the Unity Analytics privacy policy. This policy page should be presented to the user in a platform-appropriate way along with the ability to opt out of data collection.

    SessionID

    Gets the session ID that is currently recording into the sessionID field of events.

    Methods

    Name Description
    AcquisitionSource(AcquisitionSourceParameters)

    Record an acquisitionSource event, if the player has opted in to data collection (see OptIn method).

    AdImpression(AdImpressionParameters)

    Record an adImpression event, if the player has opted in to data collection (see OptIn method).

    CheckForRequiredConsents()

    Returns identifiers of required consents we need to gather from the user in order to be allowed to sent analytics events. This method must be called every time the game starts - without checking the geolocation, no event will be sent (even if the consent was already given). If the required consent was already given, an empty list is returned. If the user already opted out from the current legislation, an empty list is returned. It involves the GeoIP call. ConsentCheckException is thrown if the GeoIP call was unsuccessful.

    ConvertCurrencyToMinorUnits(string, double)

    Converts an amount of currency to the minor units required for the objects passed to the Transaction method. This method uses data from ISO 4217. Note that this method expects you to pass in currency in the major units for conversion - if you already have data in the minor units you don't need to call this method. For example - 1.99 USD would be converted to 199, 123 JPY would be returned unchanged.

    CustomData(string)

    Record a custom event that does not have any parameters, if the player has opted in to data collection (see OptIn method).

    A schema for this event must exist on the dashboard or it will be ignored.

    CustomData(string, IDictionary<string, object>)

    Record a custom event, if the player has opted in to data collection (see OptIn method).

    A schema for this event must exist on the dashboard or it will be ignored.

    Flush()

    Forces an immediately upload of all recorded events to the server, if there is an internet connection and a flush is not already in progress. Flushing is triggered automatically on a regular cadence so you should not need to use this method, unless you specifically require some queued events to be uploaded immediately.

    GetAnalyticsUserID()

    Gets the user ID that Analytics is currently recording into the userId field of events.

    OptOut()

    Opts the user out of sending analytics and disables the SDK. A final 'forget me' signal will be uploaded which will trigger purge of analytics data for this user from the back-end. If this 'forget me' event cannot be uploaded immediately (e.g. due to network outage), it will be reattempted regularly until successful upload is confirmed. This status is mainted between sessions to ensure that the signal will be uploaded eventually.

    ProvideOptInConsent(string, bool)

    Sets the consent status for the specified opt-in-based legislation (PIPL etc). The required legislation identifier can be found by calling CheckForRequiredConsents method. If this method is tried to be used for the incorrect legislation (PIPL outside China etc), the ConsentCheckException is thrown.

    RecordInternalEvent(Event)

    Allows other sources to write events with common analytics parameters to the Analytics service. This is primarily for use by other packages - as this method adds common parameters that may not be expected in the general case, for custom events you should use the CustomData method instead.

    RequestDataDeletion()

    Requests that all historic data for this user be purged from the back-end and disables data collection. This can be called regardless of whether data collection is currently enabled or disabled.

    If the purge request fails (e.g. due to the client being offline), it will be retried until it is successful, even across multiple sessions if necessary.

    SetAnalyticsEnabled(bool)

    Allows you to disable the Analytics service. When the service gets disabled all currently cached data both in RAM and on disk will be deleted and any new events will be voided. By default the service is enabled so you do not need to call this method on start. Will return instantly when disabling, must be awaited when re-enabling.

    StartDataCollection()

    Signals that consent has been obtained from the player and enables data collection.

    By calling this method you confirm that consent has been obtained or is not required from the player under any applicable data privacy laws (e.g. GDPR in Europe, PIPL in China). Please obtain your own legal advice to ensure you are in compliance with any data privacy laws regarding personal data collection in the territories in which your app is available.

    StopDataCollection()

    Disables data collection, preventing any further events from being recorded or uploaded. A final upload containing any events that are currently buffered will be attempted.

    Data collection can be re-enabled later, by calling the StartDataCollection method.

    Transaction(TransactionParameters)

    Record a transaction event, if the player has opted in to data collection (see OptIn method).

    TransactionFailed(TransactionFailedParameters)

    Record a transactionFailed event, if the player has opted in to data collection.

    In This Article
    Back to top
    Copyright © 2023 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)