cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Event Tracking - Getting Started With Usage Intelligence - Part 2

Event Tracking - Getting Started With Usage Intelligence - Part 2

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.

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.

To track events:

  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, such as 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”.

    1_Revulytics-Usage-Intelligence-Event-Categories (2).png

    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 Usage Intelligence account, select Product from the Administration menu, and open the Event Tracking Management tab.
  7. Enable tracking for each event listed and click Save. The next time you run the application and use these features, Usage Intelligence will collect the feature usage data.
  8. To view your feature usage data, select Feature & Event Tracking > Event Usage Timeline or Lifetime Event Usage from the menu. 

    Menu_FET.png

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.

To track numeric values:

  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, such as 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 the 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 Usage Intelligence Dashboard, select Product from the Administration menu, and open the Event Tracking Management tab to enable tracking for this event. 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 Revenera Support if you wish to include numeric events with your product's custom data.

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

Perform the following steps to collect user feedback.

To collect user feedback:

  1. Open the class where you will be collecting user feedback. 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, such as 5_0_0.
  3. Add the following code to submit the user feedback to Usage Intelligence. 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 test feedback, and close the application
  5. From the Usage Intelligence Dashboard, select Product from the Administration menu, and open the Event Tracking Management tab to enable tracking for this event. The next time feedback is submitted from the application, Usage Intelligence will collect this data.
  6. To view the feedback, select Feature & Event Tracking > Custom Events from the menu.
  7. 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
  8. 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

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.

To collect multiple values:

  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, such as 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 Logging a Custom Event in the Usage Intelligence 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 Usage Intelligence Dashboard, select Product from the Administration menu, and open the Event Tracking Management tab to enable tracking for this event.
  6. To view the data, select Feature & Event Tracking > Custom Events from the menu.

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!

Labels (1)
Was this article helpful? Yes No
No ratings
Version history
Last update:
‎Jun 23, 2023 04:06 PM
Updated by: