Skip to content

AppAmbit Analytics (MAUI)

Submit Analytics Events

Use this class to send analytics events from your MAUI application. To get started, make sure you've added the module to your app. For setup instructions, refer to the Getting Started guide.

Analytics with AppAmbit (MAUI)

AppAmbit Analytics gives you insight into user behavior and engagement, helping you improve your application experience. The SDK automatically collects session data and device details such as model and OS version. You can also define custom events to track interactions that matter to you. All collected data is accessible through the AppAmbit portal for analysis.

If you haven't already set up the SDK, follow the Getting Started section.

Session and Device Information

After integrating AppAmbit Analytics and starting the SDK, it will begin tracking user sessions and device information (e.g., OS version, device model) automatically—no extra code required, unless Analytics.EnableManualSession() is called.

Manual Management for Session

Info

Manual mode is disabled by default, if you need more control over sessions, events and logs you can do so by following the steps below.

In case you want to handle your session manually you must call enableManualSession, before you start using AppAmbit

    public static MauiApp CreateMauiApp()
    {
        Analytics.EnableManualSession();
        var builder = MauiApp.CreateBuilder();
        builder
            .UseMauiApp<App>()
            .UseAppAmbit("<YOUR-APPKEY>");

        return builder.Build();
    }

Warning

If this option is enabled no event, log or crash will be sent or saved locally until a session is started manually using Analytics.startSession(); anywhere in your code where you need it.

Start Session

If you already called EnableManualSession, you can now start a session manually, calling StartSession:

    await Analytics.StartSession();

If the method is called again before ending the session the call will be ignored.

End Session

If you already called EnableManualSession, and you already started a session, you can now end the session session manually, calling EndSession:

    await Analytics.EndSession();

If the method is called again before ending the session the call will be ignored.

Generate a Test Event

AppAmbit Crashes includes an API to trigger a test event, useful for verifying SDK integration. This API is only available in debug builds.

Analytics.GenerateTestEvent();

Custom Events

Track custom events to capture meaningful user interactions. Once the SDK is initialized, use the TrackEvent() method to track your events with properties. You can send up to 150 distinct event names. Also, there's a maximum limit of 120 characters per event name and 80 characters per event property name and event property value.

    Analytics.TrackEvent("Audio started", new Dictionary<string, string> {
        { "Category", "Music" },
        { "FileName", "favorite.mp3"}
    });

Properties are optional. To send a simple event without additional data:

Analytics.TrackEvent("Music clicked");