SNTT : Adding Google Analytics to the OpenNTF Xpages Wiki template

I have been working on a public facing OpenNtf Xpages Wiki for our Delivery Toolkit suite of products and I wanted to add Google Analytics.

It turned out to be straight forward once I had read a blog by  Thomas Adrian  who’s Xpages based blog really looks the business – try out the search functionality.

Step 1 – copy the Analytics code from Google

Image:SNTT : Adding Google Analytics to the OpenNTF Xpages Wiki template

Step 2 – disable the design inheritance for the wiki using application properties

Image:SNTT : Adding Google Analytics to the OpenNTF Xpages Wiki template

Step 3 – open the prtBanner Custom Control

Image:SNTT : Adding Google Analytics to the OpenNTF Xpages Wiki template

Step 4 – add an Output Script control to the Custom Control

Activate the Custom Controls Panel

Image:SNTT : Adding Google Analytics to the OpenNTF Xpages Wiki template

Position your curson in the top left corner of the prtBanner and click

Image:SNTT : Adding Google Analytics to the OpenNTF Xpages Wiki template

Select the “Output Script” Custom control from the “Other” Custom Controls menu

Image:SNTT : Adding Google Analytics to the OpenNTF Xpages Wiki template
Image:SNTT : Adding Google Analytics to the OpenNTF Xpages Wiki template

Switch to “Source” and you will see the Output Script represented by<xp:scriptBlock id=“scriptBlock1”></xp:scriptBlock>.
You can move this to the top of the other custom controls as shown below.

Image:SNTT : Adding Google Analytics to the OpenNTF Xpages Wiki template

Now paste your Google Analytics Script between the Script Block markers so that it looks like this

Image:SNTT : Adding Google Analytics to the OpenNTF Xpages Wiki template

Save the Custom Control

Application Debug Mode

A while back someone asked what was my best tip for Lotus Notes development – this is it – it is used in every single application I have developed in at least the last 5 years and it was passed on to me by my cousin ( thanks Martin )!

Most Notes forms will have hidden fields on them and those fields are really useful when it comes to understanding what is going on in an application. You can access the values in three ways :

1) use the document properties
2) change the “hide when” properties
3) – my tip – programmatically change the “hide when” properties

I used to hide the individual fields but a better way is to change the “hide when” attribute of a section rather than the individual fields ( thanks Ewan ). The hide when is linked to a notes.ini / environmental setting but you could also use a profile document.

Image:Application Debug Mode

Image:Application Debug Mode
You can then extend this functionality for other uses such as :

  • Disabling “on error” statements whilst debug mode is active so that you can see where code is falling over
  • Allowing extra action buttons to appear
  • Making parts of the form configurable.

In FoCul we actually have two versions of Debug mode. We have one which we call “Administrators Debug Mode” which reveals information to help our customers debug problems and then we have a second more powerful version called “Developers Debug Mode” which has more functionality.

Applications have a password protected  agent which turns the Debug modes on and most applications automatically cancel it when they are opened. We also have the custom toolbar buttons shown above.

Image:Application Debug Mode

The hide when on the section is

Image:Application Debug Mode

By using an environmental variable we can troubleshoot the applications on users computers without having to worry about ACL settings.