Dan Matthews
Mar 20, 2013
  2762
(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
Plug-in manager is back in CMS 12

Plug-in manager is back in the UI, what is it and how can i use it?

Luc Gosso (MVP) | Oct 6, 2022 | Syndicated blog

Display Child Pages in Content Delivery API Response

The below example will implement an instance of IContentConverterProvider to customise the serialisation of PageData and output child pages in the...

Minesh Shah (Netcel) | Oct 4, 2022

Bring the Report Center back in Optimizely CMS 12

The Report Center has been a part of Optimizely CMS since its first debut in version 5R2 in 2008, but in CMS 12, it's removed! Don't despair! Make...

Tomas Hensrud Gulla | Oct 4, 2022 | Syndicated blog

Customizing Property Lists in Optimizely CMS

Generic property lists is a cool editorial feature that has gained a lot of popularity - in spite of still being unsupported (officially). But if y...

Allan Thraen | Oct 2, 2022 | Syndicated blog

Optimizely names Luminary Senior Developer, Ynze Nunnink, OMVP

Luminary Senior Developer and Optimizely Lead, Ynze Nunnink has secured the coveted position of Optimizely MVP. Earning a Platinum badge for his...

Ynze | Oct 2, 2022 | Syndicated blog

Content Delivery API – The Case of the Duplicate API Refresh Token

Creating a custom refresh provider to resolve the issues with duplicate tokens in the DXC The post Content Delivery API – The Case of the Duplicate...

David Lewis | Sep 29, 2022 | Syndicated blog