Defining a Metric

Follow the steps below to define the metrics in the developer portal.

  1. Select the application in the developer portal.

  2. Click on the "Analytics" icon (the icon with bar graphs). .

  3. Press either the "+Add" button or "Create a Rule".

    This will bring up the "Aggregation Rules" screen.

  4. Enter the rule name and select "Event Data".

  5. Define the aggregation rule by filling the following information.

    • Fact: The field to be aggregated as a fact.
    • Aggregate: How to aggregate the fact. The available functions are: Count, Avg, Sum, Min, and Max.

      • Count: Count up the number of data with the valid values in the fact field.
      • Avg: Calculate the average of the values in the fact field.
      • Sum: Sum up the values in the fact field.
      • Min: Determine the minimum value in the fact field.
      • Max: Determine the maximum value in the fact field.

      You can also set a filter by setting the target event type (optional). If the filter is set, only the event data with this event type will be aggregated. Otherwise all event data will be aggregated (See Send event data from the mobile app to learn more).

    • Dimensions: The column(s) to be used for slicing and dicing the aggregates. Specify the following information for each dimension:

      • Label: how this dimension should be labeled in the analysis results. This is an optional field. If omitted, the original field name will be used as the label.
      • Name: which field is to be aggregated as a "dimension". The name should be 1-6 bytes in length, should start with a letter, and may contain alphanumeric characters and underscore(_).
      • Type: data type of the field value. The available types are: int, float, boolean and string.

    Currently, we do not support multi-byte characters. If you specify a field having either a multi-byte field name or field value, you will not get the expected results.

    For example, check the following example to see how we define Metric #1 (Average of "age" sliced by "city", "location", "gender" and "children") of our sample scenario.

    Next example shows how we define Metric #2 (Count of users (i.e. count of event data) sliced by "gender", "city", "location", "children" and "age") of our sample scenario. Here, we are specifying "*" as the fact and "Count" as the aggregate so as to count the number of event data sent to Kii Cloud.

    Click on "Save" when done.

  6. The new aggregation rule now appears in the list.

  7. Let us now activate the rule. Open the rule by clicking it and click on the "Activate" button to turn the rule on.

    The aggregation rule is now active. Note that the aggregation rule ID is now assigned (#17238 in this case). We will use this ID when getting the analysis results from the client SDK.