Skip to content

Analytics

Tracking the usage of a Modern Mercury Site using Application Insights.

This works by adding a click handler to the "Body" element.

The target is then inspected, and DOM parents are checked for useful information, before writing to Application Insights.

Configuration

Configuration is defined in a JSON file in the Hub Site's SiteAssets library. This file must be called mercury-analytics.json.

Sample config:

{
    "connectionString": "<connection string here>",
    "trackedProperties": ["Department", "WorkEmail", "Office"],
    "trackedPageProperties": ["MercuryBusinessUnit"]
}

  • connectionString is the Connection String of the Application Insights instance to log telemetry.
  • trackedProperties is an array of User Profile Properties that will be logged with every event.
  • trackedPageProperties is an array of Page Properties that will be logged with every event.