Custom Metrics

    Setting up a Custom Metric

    Before you can start using Custom Metrics, you need to go to the Dashboard and in the Actions column click the "Manage Custom Metrics" icon and add a custom metric.

    Metric Variables
    Your metric either tracks multiple variables' values and how they compare to each other, or it tracks a single variable's value changing over time. Category names only need to be provided in multi-variable metrics.

    Tracking which section (Sports, Technology, Entertainment) of your online news site a visitor is reading is a multi-variable custom metric.

    Tracking how many people are in the Sports section of your site is a single-variable custom metric. The configuration only hints to Inspectlet what kind of data you are providing. The metric doesn't takes its shape until you start feeding it data.

    The Metric's Result
    The metric's value is the result that you want Inspectlet to show.

    If you are tracking which section (Sports, Technology, Entertainment) of your site people are on, the resulting value for each category is the number of people in each category, or the total number of values.

    If you setup a single-variable custom metric which is recording from the server how many milliseconds it's taking to render a visitor's page, the resulting value you want is the average of all the values.

    Suppose your site gave karma to users for being active and wanted to track the total amount of karma of all your online users combined. To do this, you would setup a single-variable metric and provide the amount of karma for each user individually either server side or client side. The metric's value would be the sum of all the values.

    Metric Scopes

    When sending data to Inspectlet for a custom metric, a scope needs to be provided for how long this value should stick. The following scopes are available:

    • "event" - a one time event
    • "session" - this value remains till the browsing session is over
    • "page" - this value remains till the page is closed
    • "user" - this value is always added when this user is online

    Passing Data to the Custom Metric

    Parameters

    • mid - the Metric ID, can be found at your Dashboard
    • name (Optional) - The name of the category. Only applicable for multi-variable metrics.
    • value (Defaults to 1) - An integer value, usually 1. This field is only relevant if the Metric's result is configured to show the sum/average of all values.
    • scope (Defaults to "event") - The scope of the metric. Usually only one kind of scope is used for a single custom metric. See above for valid scope parameters.

    From the Client

    Inspectlet can gather custom metrics data from the client-side using Javascript as follows:

    __insp.push(['addCustomMetric', mid, {"name": name, "value": value, "scope": scope}]);
    

    From the Server

    Inspectlet can gather data for Custom Metrics from the server by a standard HTTP GET request. Please note that for server-side metrics, the scope can only be event. Syntax for server-side request:

    https://www.inspectlet.com/cmetrics/api/(wid)?mid=(mid)&name=(name)&value=(value)
    Not all variables in the URL are necessary. See above for more information about the parameters.

    See the Examples for a sample use case.

    Examples

    Measuring Average Server Load Time

    Inspectlet allows you to measure both server and client-side load times. Check out the page for measuring page load time.

    Optional Parameters

    Optional Parameters allow you to change your graph's appearance to better fit your metric. For example, if you are dealing with quantities of something, you probably don't need decimals to show in your graph's axis.

    • allowDecimalsX (true/false) - Defaults to true. Set this option to false to disallow decimals in the X axis of the graph.
    • allowDecimalsY (true/false) - Defaults to true. Set this option to false to disallow decimals in the Y axis of the graph.
    Help and Support
    FAQ Docs Contact Us
    2014 Inspectlet.