Logging User Actions

User (and Company) Actions are events initiated by your users within your UI such as Clicked Sign Up or Purchased a Subscription. By tracking user actions, you’re able to stitch together the entire customer journey even before a customer made any API calls so you can measure funnel metrics like Time to First Hello World and Time to Value.

Filtering user actions

Tracking user actions are normally done with a client integration such as moesif-browser-js or Moesif’s Segment plugin. If you implemented Mixpanel or Amplitude before, you may already be familiar with event-based tracking.

Moesif also has a HTTP API if you require tracking user actions in your server code also.

An example tracking actions using moesif-browser-js:

var moesif = require('moesif-browser-js');

moesif.init({
  applicationId: 'YOUR_COLLECTOR_APPLICATION_ID'
});

// The first argument (required) contains the action name string.
// The second argument (optional) contains event metadata.
moesif.track('Clicked Sign Up', {
  button_label: 'Get Started',
  provider: 'Google'
});

Event metadata

Besides the action name, you can also store event metadata such as the color of the button click or the value of plan a customer just purchased.

{
  "button_label": "Get Started",
  "provider": "Google",
  "some_object": {
      "some_sub_field": "some_value"
    }
}

Using event metadata

Now that we are tracking custom event metadata, we can create metrics reports within Moesif. For our example above, we can understand which social network login providers are used the most when either logging into an application or purchasing a plan.

In order to do so, we can go to Time Series from under Events. From there, you can open the Metadata within any of the filter/group by/metric drop downs.

Group By Event Metadata

In our example, we select metadata.provider, now our chart will show the daily API calls broken down by data center region as shown below

Logins and Purchases by Login Provider

Best practices

1. Maintain consistent data types

Moesif auto detects the data type the first time a new JSON key is seen. For example, if a field is set to 2, Moesif will treat this field as a number. You cannot send a different type using the same key. For example, if you previously sent to Moesif the following event metadata for an API call:

{
  "some_string": "I am a string",
  "some_int": 77,
  "some_object": {
      "some_sub_field": "some_value"
    }
}

Then, Moesif automatically saves some_string as a JSON string in the metadata schema. You cannot later send a JSON Number using the same some_string key. This is true regardless of the number of levels relative to the object root. The below metadata would now be invalid:

{
  "some_int": 77,
  "some_object": {
      "some_string": 23,
      "some_sub_field": "some_value"
    }
}

The metadata schema is specific to each application you create in Moesif. For example, your develop environment can be different than your prod environment.

2. Avoid dots characters

Be aware that Dot characters in a JSON key for event metadata will be converted into an underscore by Moesif automatically. Hoever, Dot characters in a JSON value are fine and will not be transformed.

For example,

{
  "so.me_str.ing": "I am a string",
  "some.int": 77.23
}

Will be converted by Moesif to:

{
  "so_me_str_ing": "I am a string",
  "some_int": 77.23
}

Updated: