Installation of NV Tag

Overview

This section guides through the process and associated steps for inserting NetVision (NV) tag inside an application.

How NetVision (NV) Works – High Level

  • It has mainly two components – NV JS Agent and NV Server.
  • When user browses an application (for example. www.example.com), NV bootstrap code is loaded along with main application.
  • NV bootstrap code loads the NV JS Agent and the configuration file.
  • NV JS Agent collects the data from browser and send that to the NV Server.
  • NV Server processes the data and uploads it to the Database.
  • NV Reporting server can be used to monitor the data.

NV Tag (nv_bootstrap.js)

  • This small piece of JS code loads the complete NV JS Agent and configuration file.
  • To monitor a web application, each page should have this NV bootstrap file (or code).

Where to Add NV Tag

  • NV Bootstrap tag should be on each page of the application. We can keep this JS Code in header file (which is common for all the pages).
  • It is recommended to keep this piece of code in such a place so it can be executed before first Onload event. (Better to keep in HEAD tag.)
  • It is recommended to add this tag using a tag manager (for example, Ensighten tag manager). That will have control to remove/add Tag dynamically.

How to Add NV Tag

There are two methods to add the NV tag.

  1. Add the content of nv_bootstrap file.
  2. Add a script tag, having src to nv_bootstrap file.

Method – 1: Add the Content of nv_bootstrap

It is recommended to add content of nv_bootstrap in the application. This allows reducing one Http Request (for nv_bootstrap).

(function(){
  var dom,doc,where,iframe = document.createElement('iframe');
  iframe.src = "javascript:false";
  (iframe.frameElement || iframe).style.cssText = "width:0;height:0;border:0;display:none;";
  if(document.body){
    where = document.body.getElementsByTagName('script')[0];
    document.body.appendChild(iframe, where);
  } else {
    where = document.getElementsByTagName('script')[0];
    where.parentNode.insertBefore(iframe, where);
  }
  try {
    doc = iframe.contentWindow.document;
  } catch(e) {
    dom = document.domain;
    iframe.src="javascript:var d=document.open();d.domain='"+dom+"';void(0);";
    doc = iframe.contentWindow.document;
  }
  function getVersion() {
    var s = null;
    if(document.querySelector) {  s = document.querySelector('[src*="nv_bootstrap"]');}
    if(!s) {
      s = document.getElementsByTagName('script');
      for(var z = 0; z < s.length; z++)
      {
        if(s[z].src && s[z].src.indexOf('nv_bootstrap') >= 0) {
          s = s[z]; break;
        }
      }
    }
    if(s && s.src && s.src.indexOf('?') > 0)
    {
      var v = s.src.substr(s.src.indexOf('?')+1).split('&')[0];
      v = v.split('=')[1] || v.split('=')[0];
      return v;
    }
    return null;
  }
  doc.open()._l = function() {
    var js = this.createElement("script");
    if(dom) this.domain = dom;
    js.id = "boomr-if-as";
    js.src = '//mon1.example.com/nv/example/cav_nv.js?v=REL20170123';
    var v = getVersion();
    if(v) {
      js.src = js.src + "?v=" +  v;
      window.top.__nv_agent_version = v;
    }
    this.body.appendChild(js);
  };
  doc.write('<body onload="document._l();">');
  doc.close();
  })();

Note: it is recommended to add release/build version in the src of cav_nv.js (NV JS Agent), as highlighted above. Please change the version accordingly.

Method – 2: Add Script Tag for nv_bootstrap

NV Server hosts the nv_bootstrap and other files. So, following script tag can be added to load nv_bootstrap.

<script src=”//mon1.example.com/nv/example/nv_bootstrap.js?v=REL20170123” type=”text/javascript”></script>

Customer User can host this JS from its own web server and then it can be referred from there also.

<script src=”//www.example.com/mon/js/nv_bootstrap.js?v=REL20170123” type=”text/javascript”></script>


Note:
As we mentioned in step first, it is highly recommended to add release/build version in URL of script (For example – v=REL20170123).  Please change the version accordingly.