Web App analytics with Azure Application Insights and WordPress

Application insights has been a great ally to help developers detect, diagnose and understand users behavior in applications. For those new to this platform, Application Insights is an analytics solution that monitors live applications no matter if they are web or a stand-alone app running Windows, iOS, OSX or Android.


In this article, we talk about a new plugin released by Microsoft that makes very easy to integrate Azure Application Insights with WordPress.


To get started, download the plugin from this link. Alternatively, go to WordPress administration -> Plugins -> Select Add New -> Search for “Azure App Insights Plugin“.

App Insights Install

If you opted for installing it manually, all you have to do is:

  1. Extract the contents to the WordPress plugins directory at wp-content\plugins.
  2. Activate the plugin by navigating to WordPress Administration -> Plugins. If you don’t see the plugin on the list, refresh the page or double check step 1.

Register the Application in Azure AD

Now we have to register the plugin as an authorized Azure AD application. Sign in to Azure Portal (classic) and navigate to Azure Directory. Choose the directory you would like to use and under Applications tab, click Add to register a new application.


Choose “Add an application my organization is developing“.


Type a familiar name for this application and select “Native Client Application


Enter a value for Redirect URL with the format http://mydomain.com.br/wp-admin/options-general.php, where the root of WordPress is also the root of the Web Server. If for some reason you changed the installation path, make the changes accordingly.


You should now see your application in the applications list. Select it and navigate to Configure Tab. Scroll down to the bottom and look for “Permissions to other applications“. Click Add application and add “Windows Azure Service Management API“, make sure to also change Delegated Permissions from 0 to 1.


A particular note, in the official documentation, they also ask you to add “Microsoft Azure Data Catalog“. The plugin worked for me without this particular permission, and in fact, I didn’t even had it on my list of Microsoft Apps to add. You are probably safe to skip this one.

Create App Insights

Now switch to preview portal and add a new Application Insights. You can read more about creating App Insights here.


Configure the plugin

Now go back to WordPress Administration and navigate to Settings -> Application Insights Dashboard


Insert your Tenant ID and Client ID then hit Authorize Plugin. You can get both IDs from the Configure Tab of your application in Azure AD.


If everything goes as expected, you should see “Plugin authorization succeeded” and a few more boxes to setup. Select the subscription, component and insert your Instrumentation Key. See the image below to know how to get this key.

On your app overview blade, choose Quick Start, Get code to monitor my web pages. Copy the script.

Copy and paste the values and click Update Options.


All done! Wait a couple minutes and you should see the metrics starting to appear in WordPress dashboard (or App Insights in preview portal).



[1] Determine your WordPress web app usage with Application Insights

[2] Visual Studio Application Insights

[3] Azure App Insights plugin

[4] Application Insights for JavaScript web apps

Leave a Reply

Your email address will not be published. Required fields are marked *