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

    Figure 224 : Accessing the URL Rewrite option

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

    Figure 225 : Choosing to add a new rule

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

    Figure 226 : Selecting the Blank Rule option

  5. Then, click the OK button in Figure 226.
  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 227). 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 227 : Defining the properties of the new precondition

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

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

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

    Figure 229 : Entering the pattern for the rule

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

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

    Figure 231 : 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 232).

    Figure 232 : Accessing the URL rewrite option

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

    Figure 233 : Choosing to add a new rule

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

    Figure 234 : Selecting the Blank Rule option

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

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

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

    Figure 237 : 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 238.

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