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 1).

    Figure 1 : Accessing the URL Rewrite option

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

    Figure 2 : Choosing to add a new rule

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

    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 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 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.

    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.

    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.

    Figure 6 : Entering the pattern for the rule

  10. Then, scroll down Figure 7 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 7. 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 7 : Specifying the line of code to be auto-injected in the head

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

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

    Figure 9 : Accessing the URL rewrite option

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

    Figure 10 : Choosing to add a new rule

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

    Figure 11 : Selecting the Blank Rule option

  15. Then, click the OK button in Figure 11.
  16. In Figure 12 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 12 : Adding the eG RUM Body Rule

  17. Then, scroll down Figure 12 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 13. 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 13 : Specifying the line of code to be auto-injected in the body

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

    Figure 14 : 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 15.

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