Monitor Integration in Javascript

This article will describe how to integrate the Telerik Analytics Javascript monitor.

The integration consists of these steps:

  1. Add the javascript library to your application
  2. Create and start the monitor
  3. Start tracking interesting statistics

Before getting started you must also have created an application so you have a product id. You will need that in the integration. Read more about how to Add Analytics to Your Application.

Please note that the Javascript monitor and reported statistics is optimized for Single-Page Applications (SPA).

Step 1: Add monitor Javascript to your project

Download the Javascript SDK file which contains the monitor file EqatecMonitor.min.js.

Include the file in your Javascript project in your favorite manner. For instance:

<script src="EqatecMonitor.min.js" type="text/javascript"></script>

Step 2: Create and start the monitor

The Javascript module contains defines the _eqatec global variable which is the gateway for interacting with the Analytics functionality. You can create and start the monitor like so:

<script src="EqatecMonitor.min.js" type="text/javascript"></script>
<script>
  (function (g) {
    if (g._eqatecmonitor)
      return;
    try {
      // Create the monitor instance
      var settings = _eqatec.createSettings("PUT-YOUR-PRODUCTID-HERE");
      settings.version = "1.2.3";
      var monitor = g._eqatecmonitor = _eqatec.createMonitor(settings);
      // Start the monitor when your application starts
      monitor.start();
    }
    catch (e) {
      console.log("Telerik Analytics exception: " + e.description);
    }
  })(window);
</script>

That's it, really. If you run your application now it will start reporting basic analytics data.

Step 3: Start tracking interesting statistics

The next natural step is to track interesting events and exceptions.

You can explore the full Analytics Javascript API for more info. Here are a few examples:

// Tracking features
g._eqatecmonitor.trackFeature("SomeFeature");

// Tracking exceptions
try {
  someOperation();
}
catch (e) {
  g._eqatecmonitor.TrackExceptionMessage(e, e.message);
}

// Tracking timing
g._eqatecmonitor.trackFeatureStart("SomeLongOperation");
someLongOperation();
g._eqatecmonitor.trackFeatureStop("SomeLongOperation");

Conclusion

After completing the integration steps in this guide, Telerik Analytics should be integrated into your application. When you run it, you should see data within 5 minutes on the Analytics client dashboard. If not then please check the article on Your First Data.

See Also

Start a free trial Request a demo
Contact us: +1-888-365-2779
sales@telerik.com
Copyright © 2016-2017, Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.