Documentation

Log Events

Mikros Analytics

Once the SDK is initialized, you can immediately start logging events (preset or custom) for analytics.

Make sure to have the following namespaces defined at the top of your scripts:

using MikrosApiClient;
using MikrosApiClient.MikrosAnalytics;

Track Custom Events

Custom events can be tracked by the following ways:

  1. To log an event without any parameters.

    AnalyticsController.LogEvent("custom_event_name", (Hashtable customEventWholeData) =>
    {
       // handle success
    },
    onFailure =>
    {
       // handle failure
    });

  2. To log an event with only one parameter of String datatype.

    AnalyticsController.LogEvent("custom_event_name", "parameter", "parameter_value", (Hashtable customEventWholeData) =>
    {
       // handle success
    },
    onFailure =>
    {
       // handle failure
    });

  3. To log an event with only one parameter of Double datatype.

    AnalyticsController.LogEvent("custom_event_name", "parameter", 1.5, (Hashtable customEventWholeData) =>
    {
       // handle success
    },
    onFailure =>
    {
       // handle failure
    });

  4. To log an event with only one parameter of Long datatype.

    AnalyticsController.LogEvent("custom_event_name", "parameter", 1, (Hashtable customEventWholeData) =>
    {
       // handle success
    },
    onFailure =>
    {
       // handle failure
    });

  5. To log an event with multiple parameters of any datatype.

    Hashtable parameterData = new Hashtable();
    parameterData.Add("parameter1", "parameter_value");
    parameterData.Add("parameter2", 1.5);
    parameterData.Add("parameter3", 1);
    parameterData.Add("parameter4", true);
    AnalyticsController.LogEvent("custom_event_name", parameterData, (Hashtable customEventWholeData) =>
    {
       // handle success
    },
    onFailure =>
    {
       // handle failure
    });

All custom events are uploaded automatically to backend at a feasible time whenever the phone is idle. However, these events can also be uploaded any time in the following way:

AnalyticsController.FlushEvents();