amplitude / amplitude-win

Amplitude SDK for Windows Apps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

!!Amplitude no longer supports Windows SDK!!

Setup

  1. If you haven't already, go to https://amplitude.com/signup and register for an account. Then, add an app. You will receive an API Key.

  2. In every file that uses analytics, add the AmplitudeSDK namespace at the top:

    using AmplitudeSDK;
  3. In the constructor of your App, initialize the SDK:

    Amplitude.Initialize(this, "YOUR_API_KEY_HERE");
  4. To track an event anywhere in the app, call:

    Amplitude.Instance.LogEvent("EVENT_IDENTIFIER_HERE");
  5. Events are saved locally. Uploads are batched to occur every 30 events and every 30 seconds. After calling LogEvent() in your app, you will immediately see data appear on the Amplitude website.

Tracking Events

It's important to think about what types of events you care about as a developer. You should aim to track between 20 and 100 types of events within your app. Common event types are different screens within the app, actions a user initiates (such as pressing a button), and events you want a user to complete (such as filling out a form, completing a level, or making a payment). Contact us if you want assistance determining what would be best for you to track.

Tracking Sessions

A session is a period of time that a user has the app in the foreground. Sessions within 15 seconds of each other are merged into a single session. In the Windows SDK, sessions are tracked automatically.

Setting Custom User IDs

If your app has its own login system that you want to track users with, you can call SetUserId() at any time:

Amplitude.Instance.SetUserId("USER_ID_HERE");

A user's data will be merged on the backend so that any events up to that point on the same device will be tracked under the same user.

You can also add a user ID as an argument to the Initialize() call:

Amplitude.Initialize(this, "YOUR_API_KEY_HERE", "USER_ID_HERE");

Setting Event Properties

You can attach additional data to any event by passing a Dictionary<string, object> as the second argument to LogEvent():

Dictionary<string, object> eventProperties = new Dictionary<string, object>()
{
    {"KEY", "VALUE"}
}
Amplitude.Instance.LogEvent("Sent Message", eventProperties);

Setting User Properties

To add properties that are associated with a user, you can set user properties:

Dictionary<string, object> userProperties = new Dictionary<string, object>()
{
    {"KEY", "VALUE"}
}
Amplitude.Instance.SetUserProperties(userProperties);

Advanced

If you want to use the source files directly, you can download them here. To include them in your project, extract the files, and then copy the five *.java files into your Android project.

This SDK automatically grabs useful data from the phone, including app version, phone model, operating system version, and language information.

By default, device IDs are a randomly generated UUID. You can retrieve the Device ID that Amplitude uses with Amplitude.Instance.GetDeviceId(). This method can return null if a Device ID hasn't been generated yet.

About

Amplitude SDK for Windows Apps

License:MIT License


Languages

Language:C# 100.0%