November Happy Hour will be moved to Thursday December 5th.

Dan Matthews
Mar 20, 2013
  3333
(1 votes)

EPiServer 7 and Live Monitor

Many of you have probably used the funky Live Monitor with EPiServer CMS 6 (otherwise known as EPiServer Trace). If you come to deploy it in EPiServer 7 and you are creating your own site using the web site template rather than starting with the Alloy templates, you may have a little difficulty in getting it running. It spins up, but no visits are ever tracked. Why is this? Well, Live Monitor works by injecting some tracking javascript into the page which, in turn, calls a handler URL to record the ‘visit’. To inject that tracking code, you need to use a new EPiServer feature called ‘Required Client Resources’. In the Alloy templates, this is done for you. However, if you started from scratch with the EPiServer web site template, you won’t have this and will need to add it yourself.

To get it all working, take a look at the following article on the SDK:

Live Monitor Configuration in EPiServer 7 (SDK)

Annoyingly, if you followed the instructions in the documentation on World rather than the SDK, then you’re probably tying yourself in knots and not getting anywhere – it’s not updated yet. If you’re interested in the background…

In EPiServer 6, getting that tracking javascript code injected could be troublesome because it requires EPiServer to be able to intercept, parse and modify the pages coming through. In an ideal world, the tracking code should be automatically inserted by EPiServer hooks that are added when you deploy Live Monitor. However, this often didn’t work because of the parsing requirements. The workaround was therefore to insert the tracking code manually by adding an ASP.NET control to the page called ‘VisitTracker’. Indeed, this is what the CMS 7 documentation on World currently tells you to do:

Live Monitor Configuration in EPiServer 7 (World) - DO NOT USE THIS!

Unfortunately, if you try and do this in EPiServer 7 then you’ll soon find out that ‘VisitTracker’ no longer exists (resulting in various missing tag prefix errors at runtime). The reason for this is that because EPiServer 7 uses this new Required Client Resources technique, there is now a much better way to inject the needed tracker javascript and it doesn’t have anything to do with manually adding controls.

Simply put, this new technique will scan all assemblies for classes that are marked with an attribute for required client resources, then it will call the classes to generate the resources (it’s an interface it calls) and insert the resulting resource references at a defined point on the page. Where these resources are inserted depends on an ASP.NET control called, unsuprisingly, ‘RequiredClientResources’. In Alloy, this is pre-set up for you in Root.Master:

<EPiServer:RequiredClientResources RenderingArea="Header" ID="RequiredResourcesHeader" runat="server" />

The solution is very simple then – simply include the RequiredClientResources controls where needed. You should add two… one in the Header and one in the Footer. The link at the top of this article will take you from here.

Mar 20, 2013

Comments

Please login to comment.
Latest blogs
Optimizely SaaS CMS + Coveo Search Page

Short on time but need a listing feature with filters, pagination, and sorting? Create a fully functional Coveo-powered search page driven by data...

Damian Smutek | Nov 21, 2024 | Syndicated blog

Optimizely SaaS CMS DAM Picker (Interim)

Simplify your Optimizely SaaS CMS workflow with the Interim DAM Picker Chrome extension. Seamlessly integrate your DAM system, streamlining asset...

Andy Blyth | Nov 21, 2024 | Syndicated blog

Optimizely CMS Roadmap

Explore Optimizely CMS's latest roadmap, packed with developer-focused updates. From SaaS speed to Visual Builder enhancements, developer tooling...

Andy Blyth | Nov 21, 2024 | Syndicated blog

Set Default Culture in Optimizely CMS 12

Take control over culture-specific operations like date and time formatting.

Tomas Hensrud Gulla | Nov 15, 2024 | Syndicated blog