Usage monitoring with Application Insights JavaScript SDK Update

Charles Sterling

Posting on the behalf of Bret Grinslade.  If you want to know more or meet Bret he will also be doing a talk on this topic at TechED 2014.



We have posted an update to the JavaScript SDK for Usage.  Going forward, any time you get the JavaScript snippet from the Keys & Downloads page it will be with the new API.  This change went out on Feb 19th 2014 Wednesday morning.

Your existing JavaScript snippet and code will continue to work as before. However, we would like you to upgrade to the new version when you can as this new version is this is the one we will support going forward for bug fixes.

For more information about the JavaScript SDK please see:


A few notes on porting:

  • The root object for the AI JavaScript SDK is now appInsights and no longer _da

  • The API names have changed to align with the Windows Store and Windows Phone SDKs

  • appInsights.logPagView to log Page Views

  • appInsights.logEvent to log Events
  • appInsights.start to Initialize with your instrumentation key
  • appInsights.appUserId (now a property and not a function) to set your custom user id (typically used for logged in users)
  • appInsights.accountId (now a property and not a function) to set your customers account or tenant id

  • The first parameter of logEvent now includes the path –  so your will need to convert your code from passing two parameters to passing one where event name is appended to the path and separated by a slash

  • Your old code like __da.trackEvent(“EventNameHere”, “My/Path/Here”);

  • Would now be appInsights.logEvent(“My/Path/Here/EventNameHere”);
  • The whole signature would look like the following:

if (appInsights) { appInsights.logEvent(

“open/buy”, // event name

// Optional properties and metric:

    {Stock : “Msft”, Property2: “Value 2”}, // Any number of string properties

    {Price: 42} //At most one numeric metric, and right now has to be an INT


  • You can also now log properties and a metric for page views.  However, in the Pages Report you can only report on the metric and not the properties at this time. 

The metric data (avg, min, max per hour) is found on the Details tab for the Pages report as it is for Events report.


If you have any question please post them at:

Thanks. -Bret


Discussion is closed.

Feedback usabilla icon