Enabling Azure App Insights Analytics to your Drupal web app

Enabling Azure App Insights Analytics to your Drupal web app

Drupal uses themes to change the look and feel of your web application. Microsoft Azure offers Visual Studio Application Insights service which allows you to get key application telemetry data out of the box, including usage and requests for PHP applications. In this blog post you will learn how to enable Application insights service in your Drupal web application.

Step1: Create an Application Insights service resource in Azure preview portal and get the JavaScript code to inject within your application. This code will allow Application insights service to track and monitor your application. To learn more, see How to get code to monitor your web pages

Step 2 : Find html.tpl.php file in your themes folder. For example, if you are using bootstrap theme, you can find the html.tpl.php file in your theme directory sites/all/themes/bootstrap/theme/system/html.tpl.php.

Step 3: Add the JS code inside this file within the <head> section

<script type="text/javascript">                                
 var appInsights=window.appInsights||function(config){ 
   function s(config){t[config]=function(){
      var i=arguments;t.queue.push(function(){t[config].apply(t,i)})}}
      var t={config:config},r=document,f=window,e="script",o=r.createElement(e),i,u;
      for(o.src=config.url||"//az416426.vo.msecnd.net/scripts/a/ai.0.js",r.getElementsByTagName(e)[0].parentNode.appendChild(o),t.cookie=r.cookie,t.queue=[],i=["Event","Exception","Metric","PageView","Trace"];
i.length;)s("track"+i.pop());return config.disableExceptionTracking||(i="onerror",s("_"+i),u=f[i],f[i]=function(config,r,f,e,o){var s=u&&u(config,r,f,e,o);return s!==!0&&t["_"+i](config,r,f,e,o),s}),t }
({ instrumentationKey:"48753cbf-e2d4-4e16-8c98-5c7aeae64e49"    });                      window.appInsights=appInsights; appInsights.trackPageView();     </script>
 

Application insights give you telemetry on how people use your application lets you focus on the scenarios that are most important to your target audience. You can gain insights into the goals that they find easier or more difficult to achieve. Application Insights provides two levels of usage tracking:

  • User, session and page view data – provided out of the box.
  • Custom telemetry – You write code to trace your users through your app’s user experience. You can use the PHP SDK for Application insights to build custom telemetry to track specific evnets for an given customer/user scenario

To learn , more about how to view and track usage telemetry click here .

Tools

  • PHP SDK for Application insights will allow you to send telemetry of various kinds (event, trace, exception, etc.) to the Application Insights service where they can be visualized in the Azure Portal. The SDK gives you the flexibility to customize how and what you track for you web application.
  • Web App Availability Testing similar to URL ping test is also supported with Application Insights service. Application Insights will send web requests at regular intervals from points around the world, and can alert you if your application responds slowly or not at all.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s