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 two outbound rules on IIS – a eG RUM Head Rule and a eG RUM Body Rule. Let’s begin by creating the eG RUM Head 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 5).

    Figure 5 : Accessing the URL Rewrite option

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

    Figure 6 : Choosing to add a new rule

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

    Figure 7 : Selecting the Blank Rule option

  5. Then, click the OK button in Figure 7.
  6. In the dialog box that appears next, enter eG RUM Head 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 8). 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.

    Figure 8 : Defining the properties of the new precondition

  8. When Figure 9 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 9.

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

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

    Figure 10 : Entering the pattern for the rule

  10. Then, scroll down Figure 11 to view the Action Properties section. Here, enter that portion of the eG-generated JavaScript code snippet that needs to be injected into the head (and not the body) of the web pages to be monitored. Typically, the line of code that captures the date/time at which the JavaScript code snippet began execution should be injected into the head. For instance, consider the sample JavaScript code snippet below:

    <!-- RUM Header -->

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

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

    window['Site_Name'] = '57bf9bbe-5712-40e9-929b-f75c5ab300e9-1606389009637';

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

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

    </script>

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

    <!-- RUM Header -->

     

    Here, the line of code highlighted in Bold is the one that needs to be auto-injected into the head of all web pages of the chosen web site.

    To ensure this, type this entire line of code in the Action Properties section of Figure 11. Make sure that you append the line with the entry {R:0}. So, your complete Action Properties specification will be as follows:

    <script charset='UTF-8' type='text/javascript'> window['egrum-start_time'] = new Date().getTime(); </script>{R:0}

    Figure 11 : Specifying the line of code to be auto-injected in the head

  11. Finally, click the Apply button in Figure 12.

    Figure 12 : Applying the changes

  12. With that the eG RUM Head rule has been defined. Now, let us proceed to define the next rule – the eG RUM Body rule. For that, once again 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 13).

    Figure 13 : Accessing the URL rewrite option

  13. When Figure 14 appears, select the Add Rule(s) option.

    Figure 14 : Choosing to add a new rule

  14. In Figure 15 that then appears, click the Blank Rule option.

    Figure 15 : Selecting the Blank Rule option

  15. Then, click the OK button in Figure 15.
  16. In Figure 16 that appears next, enter eG RUM Body Rule as the name of the new rule. From the Precondition list, pick the isHtmlContent option. Then, against Pattern specify </body[^>]*>.

    Figure 16 : Adding the eG RUM Body Rule

  17. Then, scroll down Figure 16 to view the Action Properties section. Here, enter that portion of the eG-generated JavaScript code snippet that needs to be injected into the body (and not the head) of the web pages to be monitored. Typically, the line of code that connects to the eG RUM Collector and runs the egrum.js script should be injected into the body. For instance, consider the sample JavaScript code snippet below:

    <!-- RUM Header -->

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

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

    window['Site_Name'] = '57bf9bbe-5712-40e9-929b-f75c5ab300e9-1606389009637';

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

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

    </script>

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

    <!-- RUM Header -->

     

    Here, the line of code highlighted in Bold is the one that needs to be auto-injected into the body of all web pages of the chosen web site.

    To ensure this, type this entire line of code in the Action Properties section of Figure 17. When doing so, make sure that the following are in place:

    • The curly braces in the code snippet should be encoded. For this, you need to replace the 'opening curly braces' in the code snippet with {UrlDecode:%7B}, and the 'closing curly braces' with {UrlDecode:%7D}
    • Append {R:0}.to the entire code snippet.

    So, your complete Action Properties specification will be as follows:

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

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

    window['Site_Name'] = '57bf9bbe-5712-40e9-929b-f75c5ab300e9-1606389009637';

    window['beacon-url'] = 'http://192.168.8.33: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, overwriteBtmUName:false, excludeURLPattern:'none', ajaxExcludeURLPattern:'none', includeURLPattern:'*'{UrlDecode:%7D};{UrlDecode:%7D})(window['egrum-config']);

    </script>

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

    Figure 17 : Specifying the line of code to be auto-injected in the body

  18. Finally, click the Apply button in Figure 18.

    Figure 18 : Applying the changes

  19. Once both the rules have been created, click Browse. After the page loads successfully, view the source code of that web page to ensure that the JavaScript code snippet has been injected as expected.

    Alternatively, you can also auto-inject the JavaScript code snippet into only those web pages that match specific URL patterns. To achieve this, in both the rules, add conditions to match the URL patterns, as depicted by Figure 19.

  20. Figure 19 : Auto-injecting the code snippet in web pages that match specific URL patterns