Simple Feedback for Usage Analytics

Like my previous posts on Usage Analytics this topic appears regularly in my work. In the previous posts I described setting up App Insights for use in Office development and how to attach Custom Events to actions in SharePoint site elements so that we can easily take measurements (think Lean Startup) as we develop stories.

Sometimes though we do not have the benefit of a user action to confirm that a story was useful. For example, when we display information like today’s Special in the Cantina or the next public holiday. For these cases we can employ a simple feedback mechanism using the same back-end service. All that we need is a little HTML to display buttons but I have added a helper function to send event properties so that we can have more measurements in one instance and still tell the results apart.

Was this helpful?
Yes, but not perfect.

You can style the table however you want- this one is much too large for most uses. The table code, without special Style, looks like this:

<table style="width:100%;border:1px solid black;" bgcolor="#D3D3D3">
  <td colspan="2">Was this helpful?</td>
  <tr >
    <td style="width:50%;border:1px solid #999999;" onclick="UsageEvent({NewPanel:'yes'}); = '#cce5cc';">YES</td> 
    <td style="width:50%;border:1px solid #999999;" onclick="UsageEvent({NewPanel:'no'}); = '#cce5cc';">NO</td>
    <td colspan="2" onclick="UsageEvent({NewPanel:'other'}); = '#cce5cc';">Yes, but not perfect.</td>

Note that the onclick action is a function. The input is a JSON containing a property name and value.  The UsageEvent function looks like this:

function UsageEvent (eventProperties) {

For this example I moved away from the simple “Your Event Here” model as previously described because I might want to track lots of different events, some “Feedback” events and others that are various types of Actions. The “properties” model allows me have a handful of top-level entries, like “Feedback” which can be sorted or charted separately in the App Insights console based on their properties.