Web Agent on IIS (URL Rewrite)
Recommended way to inject the Web agent JavaScript into websites running on IIS 7.0+.
Note: It's still best to use the ISAPI Filter for special application like MS CRM 2011, because Rewrite rules can conflict with the XML/JSON content that CRM sends as text/html type.
Downloading URL Rewrite
You can use the Microsoft Web Platform Installer to install the URL Rewrite module or download the installers manually from http://www.iis.net/downloads/microsoft/url-rewrite
Microsoft Web Platform Installer
- Open IIS Manager
- Select server
- Select Web Platform Installer
- Search for URL Rewrite
- Select it and press Install
Manually
- Select additional downloads from http://www.iis.net/downloads/microsoft/url-rewrite#additionalDownloads
- Download x86 or x64 bit depending on your Server OS bitness.
- Run the proper installer on the IIS server and install with default options.
Configure URL Rewrite on site
- Download the Web agent JavaScript from download page, unzip the file and place it in a directory on the server where it's available to the users.
- Start IIS Manager
- Select the Site you want to inject the Web agent JavaScript on.
- Select URL Rewrite module
- Select "Add Rule(s)..."
- Select a "Blank rule" under Outbound rules.
- Name: Enter "Inject Web agent JS on all pages"
- Precondition:
Select <Create New Precondition...> and call it "IsHTML", you can also select the existing one if it's already created.
Add new condition to the Precondition, that checks if ContentType starts with ^text/html.
All pages that matches this Precondition will get the UXM Web agent injected.
Condition input: {RESPONSE_CONTENT_TYPE}
Pattern: ^text/html
Click OK to create the precondition: - Match is what URL Rewrite searches for on the HTML page, we normally search for the </title> tag and try to insert our own JavaScript code after it.
Matching scope: Response
Content: Matches the Pattern
Using: Regular Expressions
Pattern: </title> - Action is what it does when the Match pattern is found, we replace the title with a new title tag and append our Web agent script code.
You can use the Agent Options to see available settings for configuring the Web agent or see Manually setup for more information on how to setup and configure the agent.
Example tag:
key (Required): Has to be replaced with unique value, we normally use 'ServerName_WebSiteName'
server (Required): Collector where collected metrics is send to, use customername.mcg.dk for SaaS installations and your IP or DNS for On-Premise installations.
</title><script src="/uxm_web_agent.min.js" data-uem-config="key: '{CreateUniqueKey}', server: 'customername.mcg.dk', captureAjax: true, sendScreenSize: true" type="text/javascript"></script>
Troubleshooting
HTTP Error - 500.52 - URL Rewrite Module Error
Outbound rewrite rules cannot be applied when the content of the HTTP response is encoded ("gzip")
URL Rewrite tries to inject our HTML code into your sites HTML code, it can't do this if URL Rewrite executes after the content is Dynamically Compressed (gzip).
You can change the order so URL Rewrite runs before the Dynamically Compression.
- Start IIS Manager
- Select Modules
- View Ordered List...
- Find URL Rewrite and move it up before Dynamic Compression
- Run an IISRESET