- Revenera Community
- :
- Usage Intelligence
- :
- Usage Intelligence Knowledge Base
- :
- Event Tracking - Getting Started With Usage Intelligence - Part 2
- Mark as New
- Mark as Read
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
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.
- SDK Integration - Getting Started with Usage Intelligence - Part 1
- Event Tracking - Getting Started with Usage Intelligence - Part 2
- Software License Usage Tracking - Getting Started with Usage Intelligence - Part 3
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:
- Open the class where you will be adding the event tracking capabilities.
- 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.
- Add the following method which will be called every time you want to track an event:
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”.private void TrackFeatureUsageEvent(string eventName) { //rui is your RUISDK instance rui.TrackEvent("Feature Usage", eventName); }
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. - 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… }
- Build your solution, run the application, execute the events which trigger event tracking, and close the application
- Log in to your Usage Intelligence account, select Product from the Administration menu, and open the Event Tracking Management tab.
- 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.
- To view your feature usage data, select Feature & Event Tracking > Event Usage Timeline or Lifetime Event Usage from the menu.
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:
- 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
- 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.
- Declare a private variable which will be used to save the time when the wizard was started:
DateTime timeOpened;
- 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…}
- 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:
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.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)); }
- Build your solution, run the application, execute the events which trigger event tracking, and close the application.
- 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:
- 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.
- 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.
- 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:
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.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… }
- Build your solution, run the application, submit test feedback, and close the application
- 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.
- To view the feedback, select Feature & Event Tracking > Custom Events from the menu.
- 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
- 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:
- 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
- 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.
- 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:
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.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… }
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.
- Build your solution, run the application, execute the events which trigger event tracking, and close the application.
- From the Usage Intelligence Dashboard, select Product from the Administration menu, and open the Event Tracking Management tab to enable tracking for this event.
- 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!