Google Analytics Razor HelperMay 19, 2011 -
I experimented today with the Razor helper syntax to consolidate generation of the Google Analytics tracking boilerplate (in ~/App_Code/Helpers.cshtml):
which can then be used in your layout pages with:
It's a bit unclear where this mechanism should fit between custom HtmlHelper extension methods and Razor partial views. I guess you'd be looking for functionality that's less generic than an HtmlHelper extension - you can modify without recompiling, and it's less simple to share between projects - and smaller/more generic than a partial.
The App_Code requirement for sharing between pages is not ideal, particularly as HtmlHelper extension methods aren't available without workarounds. Hopefully the team get an update out in a reasonably timeframe.