Using the Microsoft URL rewriter to inject webtuna.js in to your IIS site
This technique is useful if you have a third party application and don’t have a master page or source code which you can edit to include the webtuna.js in the
of the pages.The technique is described in more detail here although in our example we add the webtuna.js to the
of the page rather than the end of the http://learn.iis.net/page.aspx/658/using-outbound-rules-to-add-web-analytics-tracking-code/It is strongly recommended you try this on a test server first before doing this on a production
- Install URL Rewrite from here http://www.iis.net/download/urlrewrite
- Open IIS Manager, click on your site and then open the URL Rewrite feature
- In the Outbound Rule section click View Preconditions and the Add to add a new condition called IsHTML. The condition need check {RESPONSE_CONTENT_TYPE} matches the pattern “^text/html”. This is so that we only insert our JavaScript code into HTML and not into any other content type.
- Next if you go back to Rule and add an new Outbound rule -> Blank rule
- The Outbound rule should check for our Precondition “IsHTML”, and then Match on a pattern “” using an “Exact Match”. In the Action section we have a rewrite action which then rewrites “” as “” i.e appending the extra code needed in the HEAD from here)
- Now create another Outbound in the same way this time the rule should check for our Precondition “IsHTML”, and then Match on a pattern “” using an “Exact Match”. In the Action section we have a rewrite action which then rewrites “” as “” i.e appending the extra code needed in the BODY from here)
- Finally navigate to your web page and “view page source“ to verify the rewrite rule is working.