Viewtracker plugin on every page


I added a comment to question but it's gone now, so I'll make it a whole new question.

I've tried the code Remo Siegwart gave, but it didn't do what it supposed to do. Now I'm doing this for the first time so I'd like some help with it.

As you said, I've added it after the body, here's my code:

<body #onLoadAttr() id="com-atlassian-confluence" class="#if ($darkFeatures.isFeatureEnabled("lighter-editor-v1")) lighter-editor #end $!theme.bodyClass $!sitemeshPage.getProperty("page.bodyClass") aui-layout aui-theme-default">

<div class="wiki-content">




But now my Dashboardpage repeats itself with a error: "Error formatting macro: viewtracker: java.lang.NullPointerException" Other pages don't show any difference.


After that, I've tried it after the body, at the end, because that's also a way to understand what you mean, so my code is this:


<div class="wiki-content">





My Dashboardpage now has a very ong empty space underneath it with again the error: "Error formatting macro: viewtracker: java.lang.NullPointerException". Other pages don't show any difference.

I don't know what to do next, any help?

6 answers

This widget could not be displayed.

Hi Vera,

Both of your attempts are not correct. The only thing you need to do is to paste the line $helper.renderConfluenceMacro("{viewtracker}") right after the velocity variable $body (not the body HTML tag). The rest of the code you leave unchanged.

I recommend that you first reset the whole page layout and start again. Make sure you use the page layout and not the global layout. Atlassian documentation: Customising Site and Space Layouts

I hope this helps.


Hello, Thank you for your quick help. I was wondering if I was editing the right Layout: I did Main, but I'm no thinking I have to have Page Layout? And if so, which $body should I use? Because there are 3... Sorry & thanks again!

You have to use the page layout. → Confluence Administration → Layouts (under Look & Feel) → Create custom (Page Layout under Content Layouts) In the page layout you will find a $body variable in a HTML div. You'll have to add the Viewtracker macro there: <div id="main-content" class="wiki-content"> $body $helper.renderConfluenceMacro("{viewtracker}") </div> Please refer to the [Viewtracker add-on documentation FAQ|] as well, expand the question "How can I include the Viewtracker macro on every page?" Kind Regards, Thomas

Hi Thomas, Found it, added it and it works. 2 questions, to be sure: 1. It's only possible with the default theme, i think? 2. Is is possible to hide it with e.g. the Show if Macro?

Hi Vera, 1. Most likely yes. Themes do bring their own layout templates that overwrite the one you configured in Confluence. I'm not entirely sure that if a theme does not contain a template for the page layout, your customisations to the page layout might still work but this is not the case with the documentation theme that ships with Confluence. However, you could have a look at the Enterprise Theme, with which it would be much easier to include the Viewtracker macro on every page: * * 2. If you hide the Viewtracker macro with the show-if macro (e.g. show it only to Confluence administrators) then you would only count the views of those administrators. The proper way to use the Viewtracker macro and the show-if macro is described as well in the Viewtracker dokumentation FAQ (, expand the question "How can I make the Viewtracker macro only visible to administrators?" In your case the line you would want to insert into the page template would look like this (everything has to be on one line even it will most likely have a line break here in my reply!): $helper.renderConfluenceMacro("{viewtracker:hide=true}{show-if:group=confluence-administrators}{viewtracker-report}{show-if}") Kind Regards, Thomas

This widget could not be displayed.


Is it possible to do this using the documentation theme, and how? Thank you smile

No, tried that, not possible in Doc theme. But you can change the way the sidebar looks so it looks almost the same as in the doc theme.

This widget could not be displayed.

Sorry just to clarify, I am wanting to add the viewtracker plugin to one particular training manual in one space. Do I have to manually add it to every page or is there a workaround? Thanks again smile

This widget could not be displayed.

Please respond to Debbie Ryan not Chris Johnston. Thanks

This widget could not be displayed.

Hello all!

It works and it only shows to administrators. BUT.... only on the highest level, not on child-pages and child-child-pages....

How come and how to fix? Thank you!

This widget could not be displayed.

We've updated the documentation for this:

How can I include the Viewtracker macro on every page?

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Monday in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

229 views 2 4
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you