Visual Studio Application Insights (preview) is an extensible analytics service that helps you understand the performance and usage of your live application. It’s designed for developers, to help you continuously improve the performance and usability of your app.

This analytics service provides you with a JavaScript code to inject in your web application pages so you can start gathering telemetry about your usage. In this blog post I will show you how to configure Azure Application Insights within your WordPress app running anywhere.

Step 1: Install

  • Download the plugin.
  • Extract the plugin to the plugins directory of the WordPress installation under wp-content\plugins.
  • Activate the plugin by logging into WordPress as Administrator, then navigate to the list of plugins.
  • Check the associated checkbox for the plugin and click Activate.

Step 2: Register an Azure Active Directory application

For these steps, you must have an Azure subscription with access to the Azure Active Directory tenant.

  • Sign in to the Azure Preview Portal and navigate to Active Directory. Choose the directory (tenant) you would like to use. This should be the directory linked to your Azure subscription.
  • Under the Applications tab, click Add to register a new application.
  • Select Add an application my organization is developing, and a recognizable name. Select the application type as Native client application.
  • Enter a value for Redirect URL with the format http://www.example.com/wp-admin/options-general.php.

Step 3: Create Application Insights on Azure Portal

  • Create an Application Insights resource in the Azure Preview Portal. Learn how to create a Application Insights resource here.

Step 4: Configure the plugin

  • Login in using your Microsoft Azure credentials.
  • Navigate to Settings –> Application Insights Dashboard.
Microsoft Azure Application Insights Settings
  • Enter the Tenant ID and Client ID, then click Authorize Plugin. You can find these values under the Configure tab of your Azure Active Directory application in the Azure Preview Portal.
  • Enter the Instrumentation Key you received from your Azure App Insights resource.
Instrumentation Key
  • Once the plugin successfully configured, you can see the metrics in your WordPress dashboard.
Metrics in WordPress Dashboard
  • The dashboard can provide you with information on Users, Sessions, Page Views, Server Response Time, etc..
Dashboard Info

Conclusion

Visual Studio Application Insights (preview) can help detect issues and provide insights on user traffic to continuously improve your application. If needed, you can always use Application Insights PHP SDK to build custom tracking events.