Revenera logo

In the second article of this 3 part series, we will be using the Usage Analytics event tracking capabilities to log custom data from our calculator application. We will continue to use the simple calculator application and the .NET SDK with C# code examples to demonstrate these steps.

1. Tracking Events

In this example we will be using event tracking to record every time a user uses a particular feature. For our calculator application, we will be logging how many times the addition, subtraction, multiplication, and division features are used.

  1. Open the class where you will be adding the event tracking capabilities
  2. At the top of the file add the directive using RUISDK_<x_x_x>; where x_x_x is the SDK version you downloaded, e.g. 5_0_0
  3. Add the following method which will be called every time you want to track an event:
    private void TrackFeatureUsageEvent(string eventName) { //rui is your RUISDK instance rui.TrackEvent("Feature Usage", eventName); } 

    The TrackEvent() method has 2 required string parameters, the category of the event being tracked and the name of the event, and an optional string parameter to specify the session ID. The category is used to group events in the reports and in this example we have called it “Feature Usage”.

    Software Feature Usage tracking with Events - Revulytics

    Since our application does not manage sessions itself we have not specified the session ID parameter. We will specify the name of the event when we call this method.

  4. Whenever you would like to track a feature usage event, add a call to the method we just created. In our calculator application we have added this in the Click event of the addition, subtraction, multiplication, and division buttons:
    private void btnPlus_Click(object sender, EventArgs e)
    {
    TrackFeatureUsageEvent("Addition");
    
    //The rest of your code…
    }
  5. Build your solution, run the application, execute the events which trigger event tracking, and close the application
  6. Log in to your Revulytics account, navigate to the Administration page and under Product Settings click on Event Tracking Whitelist Management
  7. Enable tracking for each event listed and click Save
  8. The next time you run the application and use these features, Revulytics will collect the feature usage data
  9. To view your feature usage data, from your Revulytics Product Dashboard go to Feature & Event Tracking > Event Usage Timeline or Lifetime Event UsageRevulytics Usage Intelligence Event Tracking 

2. Tracking Numeric Values

Usage Intelligence gives you the capability to track and report on numeric values associated with events. In this example we will be tracking the time it takes a user to complete a Configuration Wizard to configure settings for the calculator application.

  1. Open the class where you will be adding the event tracking capabilities. In our example this is the class where we have the code for the Configuration Wizard
  2. At the top of the file add the directive using RUISDK_<x_x_x>; where x_x_x is the SDK version you downloaded, e.g. 5_0_0
  3. Declare a private variable which will be used to save the time when the wizard was started:
    DateTime timeOpened;
     
  4. When the wizard starts, set the variable to the current time. We are setting this value in the Load event of wizard:
    private void frmConfigWizard_Load(object sender, EventArgs e)
    {
    timeOpened = DateTime.Now;
    
    //The rest of your code…}
    
  5. Add the following code when the user has finished configuring the settings. In this example we are using the Click event of the Finish button:
    private void btnFinish_Click(object sender, EventArgs e) { //Calculate time difference in minutes since the wizard //was started double timeTaken = (DateTime.Now - timeOpened).TotalMinutes;  //rui is your RUISDK instance rui.TrackEventNumeric("Config Time", "Config Wizard", Math.Round(timeTaken, 2)); } 

    The TrackEventNumeric() method has 3 required parameters, the category of the event being tracked, the name of the event and a double value, and an optional parameter for the session ID. In this example we have called the category “Config Time” and the event name “Config Wizard”. We specified the value as the total time in minutes (rounded to 2 decimal places) taken by the user to complete the Configuration Wizard. Since our calculator application does not manage sessions itself we have not specified the session ID parameter.

  6. Build your solution, run the application, execute the events which trigger event tracking, and close the application
  7. From the Revulytics Product Dashboard go to the Administration page and under Product Settings click on Event Tracking Whitelist Management to enable tracking for this event
  8. The next time the Configuration Wizard runs, Usage Intelligence will collect the configuration time data

Numeric events can also be collected as custom data but this functionality needs to be enabled per product. Read the following section for more information on custom events and contact support if you wish to include numeric events with your product’s custom data.

3. Tracking Custom Events

There are times when you need to track events with free text data, for instance to record the state of your application when an event occurs, or collect manual or automated feedback from the application. This can easily be done with Usage Intelligence and in the following examples we will collect user feedback from the calculator application, and the settings chosen by users when completing the Configuration Wizard.

Collecting User Feedback

  1. Open the class where you will be collecting the user feedback from. In our example we have created a form with a textbox (txtFeedback) for users to enter their comments and a Submit button
  2. At the top of the file add the directive using RUISDK_<x_x_x>; where x_x_x is the SDK version you downloaded, e.g. 5_0_0
  3. Add the following code to submit the user feedback tRevulytics. In this example we have used the Click event of the submit button:
    private void btnSubmit_Click(object sender, EventArgs e) {  //rui is your RUISDK instance rui.TrackEventText("Feedback", "User Comments", txtFeedback.Text);  //The rest of your code… } 

    The TrackEventText() method has 3 required parameters, the category of the event being tracked, the name of the event and a string value, and an optional parameter for the session ID. In this example we have called the category “Feedback” and the event name “User Comments”. We have set the string value as the text that the user entered in the textbox and did not specify a session ID since our calculator application does not manage sessions itself.

  4. Build your solution, run the application, submit a test feedback, and close the application
  5. From the Revulytics Product Dashboard go to the Administration page and under Product Settings click on Event Tracking Whitelist Management to enable tracking for this event
  6. The next time feedback is submitted from the application, Revulytics will collect this data
  7. To view the feedback, from the Product Dashboard go to Feature & Event Tracking > Custom EventsRevulytics Custom Event Tracking Menu
  8. The Recent Custom Events tab shows the latest events that have been logged. Click on an event to see the event information submitted to Usage Intelligence, as well as additional metadata for each event including the application version and build, operating system and language information, device type, screen resolution and more
  9. The Downloadable Archives tab provides a list of zip files containing the collected data in the CSV format. These files can be downloaded for further analysis and contain all the event information and metadata described above

Collecting Multiple Values

Monetzation Monitor icon

Revenera’s Monetization Monitor

Our latest research reports explore trends around software monetization, usage analytics, piracy, and compliance.

In this example we need to collect multiple values that represent the settings chosen by the user. This can be done by using a delimiter of your choice, and in this example we chose to split our list using the “|” character.

  1. Open the class where you will be collecting the data from. In our example this is the class where we have the code for the Configuration Wizard
  2. At the top of the file add the directive using RUISDK_<x_x_x>; where x_x_x is the SDK version you downloaded, e.g. 5_0_0
  3. Create a string containing the piped list (text delimited by the | character) and log the event. In this example, we are tracking which configuration settings users are selecting in the Configuration Wizard, i.e. Normal or Scientific mode, the UI theme, and whether to keep a history or not:
    private void btnFinish_Click(object sender, EventArgs e) { StringBuilder configData = new StringBuilder(); configData.Append(rbStandard.Checked ? "Standard" : "Scientific"); configData.Append(" | " + cmbTheme.SelectedValue.ToString()); configData.Append(chkHistory.Checked ? " | Keep History" : " | Don't Keep History");  //rui is your RUISDK instance rui.TrackEventText("Config Settings", "Config Wizard", configData.ToString(), null);  //The rest of your code… } 

    Alternatively you may use the TrackEventCustom() function to collect a set of key/value pairs. The values collected will be automatically formatted as (Key1:Value1)&&(Key2:Value2) by the SDK. More information on how to use this function can be found in the documentation.


    NOTE:
    rbStandard is the radio button to select Standard mode, cmbTheme is a combo box containing a list of themes, and chkHistory is a checkbox to select whether to keep a history or not.

  4. Build your solution, run the application, execute the events which trigger event tracking, and close the application
  5. From the Revulytics Product Dashboard go to the Administration page and under Product Settings click on Event Tracking Whitelist Management to enable tracking for this event
  6. To view the data, from the Product Dashboard go to Feature & Event Tracking > Custom Events

That is it for event tracking. Check the next article on how you can manage your licensing with Usage Intelligence and track licensing specific events!