Dan Matthews
Mar 20, 2013
  3283
(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
Opti ID overview

Opti ID allows you to log in once and switch between Optimizely products using Okta, Entra ID, or a local account. You can also manage all your use...

K Khan | Jul 26, 2024

Getting Started with Optimizely SaaS using Next.js Starter App - Extend a component - Part 3

This is the final part of our Optimizely SaaS CMS proof-of-concept (POC) blog series. In this post, we'll dive into extending a component within th...

Raghavendra Murthy | Jul 23, 2024 | Syndicated blog

Optimizely Graph – Faceting with Geta Categories

Overview As Optimizely Graph (and Content Cloud SaaS) makes its global debut, it is known that there are going to be some bugs and quirks. One of t...

Eric Markson | Jul 22, 2024 | Syndicated blog

Integration Bynder (DAM) with Optimizely

Bynder is a comprehensive digital asset management (DAM) platform that enables businesses to efficiently manage, store, organize, and share their...

Sanjay Kumar | Jul 22, 2024

Frontend Hosting for SaaS CMS Solutions

Introduction Now that CMS SaaS Core has gone into general availability, it is a good time to start discussing where to host the head. SaaS Core is...

Minesh Shah (Netcel) | Jul 20, 2024

Optimizely London Dev Meetup 11th July 2024

On 11th July 2024 in London Niteco and Netcel along with Optimizely ran the London Developer meetup. There was an great agenda of talks that we put...

Scott Reed | Jul 19, 2024