How to Use the URL Rewrite Module

Once all the aforesaid pre-requisites are fulfilled, proceed to use the URL Rewrite module. For that:

  1. Create an outbound rule on IIS and name it as eG RUM Rule .

  2. For this, first select the web site (say, Default Web Site) that is to be RUM-enabled from the tree structure in the left panel of the IIS manager console. Then, from the right panel, select the URL Rewrite option (see Figure 1).

    Accessing URL Rewrite Option

    Figure 1 : Accessing the URL Rewrite option

  3. When Figure 2 appears, select the Add Rule(s) option.

    Choosing to add New Rule

    Figure 2 : Choosing to add a new rule

  4. In Figure 3 that then appears, click the Blank Rule option under Outbound rules.

    Selecting Blank Rule Option

    Figure 3 : Selecting the Blank Rule option

  5. Then, click the OK button in Figure 3.
  6. In the dialog box that appears next, enter eG RUM Rule as the name of the new rule. From the Precondition list, pick the <Create New Precondition…> option.
  7. The Add Precondition dialog box then appears (see Figure 4). Here, enter isHtmlContent as the Name of the new precondition. Then, choose Regular Expressions from the Using drop-down, and Match All from the Logical grouping drop-down. Finally, click the Add button.

    Defining Properties of New Precondition

    Figure 4 : Defining the properties of the new precondition

  8. When Figure 5 appears, type {RESPONSE_CONTENT_TYPE} as the Condition input. Then, select Matches the Pattern from the Check if input string drop-down and type ^text/html as the Pattern. Finally, click the OK button in Figure 5.

    Providing Condition Input, Input string, and Pattern

    Figure 5 : Providing the condition input, input string, and pattern

  9. You will now return to Figure 6. Now, in the Pattern text box therein, type </head[^>]*>, as indicated by Figure 6.

    Entering Pattern for Rule

    Figure 6 : Entering the pattern for the rule

  10. Now, open a Notepad Editor, and copy the eG-generated JavaScript code snippet to it. A sample snippet is given below:

    <script charset='UTF-8' type='text/javascript'>

    window['egrum-start_time'] = new Date().getTime();

    window['Site_Name'] = '95adbb30-0311-4175-ba0e-f2e9118aa1bb-1719376555987';

    window['beacon-url'] = 'http://172.16.8.148:7077';

    if(!window['egrum-config']) window['egrum-config'] = {}; (function (config) {config.capture = { jsError:true, resourceDetails:true, ajax:true, ajaxCorrelation:false, fetch:false, spa:false, overwriteBtmUName:false, excludeURLPattern:'none', ajaxExcludeURLPattern:'none', includeURLPattern:'*'};})(window['egrum-config']);

    </script>

    <script src='http://172.16.8.148:7077/rumcollector/egrum.js' async> </script>

  11. Then, make the following changes to the copied snippet:

    • The curly braces used within the code snippet should be encoded. For that, first, scan the code snippet for opening and closing curly braces. Once you isolate them, replace all the opening curly braces - i..e., { - with {UrlDecode:%7B}. Similarly, replace all the closing curly braces - i.e., } - with {UrlDecode:%7D}. Once the changes are done, your code snippet will look like this:

      <script charset='UTF-8' type='text/javascript'>

      window['egrum-start_time'] = new Date().getTime();

      window['Site_Name'] = '95adbb30-0311-4175-ba0e-f2e9118aa1bb-1719376555987';

      window['beacon-url'] = 'http://172.16.8.148:7077';

      if(!window['egrum-config']) window['egrum-config'] = {UrlDecode:%7B}{UrlDecode:%7D}; (function (config) {UrlDecode:%7B}config.capture = {UrlDecode:%7B} jsError:true, resourceDetails:true, ajax:true, ajaxCorrelation:false, fetch:false, spa:false, overwriteBtmUName:false, excludeURLPattern:'none', ajaxExcludeURLPattern:'none', includeURLPattern:'*'{UrlDecode:%7D};{UrlDecode:%7D})(window['egrum-config']);

      </script>

      <script src='http://172.16.8.148:7077/rumcollector/egrum.js' async> </script>

       

      Pay attention to the text strings in Bold in the sample snippet above. Those represent the curly braces expressed in encoded form.

    • Next, append the text string {R:0} to the code snippet. For instance, in the sample snippet above, enter {R:0} as indicated below:

      <script charset='UTF-8' type='text/javascript'>

      window['egrum-start_time'] = new Date().getTime();

      window['Site_Name'] = '95adbb30-0311-4175-ba0e-f2e9118aa1bb-1719376555987';

      window['beacon-url'] = 'http://172.16.8.148:7077';

      if(!window['egrum-config']) window['egrum-config'] = {UrlDecode:%7B}{UrlDecode:%7D}; (function (config) {UrlDecode:%7B}config.capture = {UrlDecode:%7B} jsError:true, resourceDetails:true, ajax:true, ajaxCorrelation:false, fetch:false, spa:false, overwriteBtmUName:false, excludeURLPattern:'none', ajaxExcludeURLPattern:'none', includeURLPattern:'*'{UrlDecode:%7D};{UrlDecode:%7D})(window['egrum-config']);

      </script>

      <script src='http://172.16.8.148:7077/rumcollector/egrum.js' async> </script>{R:0}

  12. Then, scroll down Figure 7 to view the Action Properties section. Copy the RUM code snippet that you modified at step 11 above and paste it in the Action Properties section. :

    Specifying Code Snippet to be Auto-injected in Head

    Figure 7 : Specifying the code snippet to be auto-injected in the head

  13. Finally, click the Apply button in Figure 8.

    Applying Changes

    Figure 8 : Applying the changes

  14. With that the eG RUM Rule has been defined.

  15. Once the rule has been created, click Browse to view the web page. After the page loads successfully, check the source code of that web page to ensure that the JavaScript code snippet has been injected as desired.