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

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

And starting with version 5 we built in a feature allowing tracking on all pages without the need of putting the macro on every page. Just as addition. :)

Check out our Administrator's Guide


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.

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

Please respond to Debbie Ryan not Chris Johnston. Thanks

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!

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 12, 2019 in Confluence

Confluence Admin Certification now $150 for Community Members

More and more people are building their careers with Atlassian, and we want you to be at the front of this wave! Important Dates Start the Certification Prep Course by 2 April 2019 Take your e...

414 views 2 13
Read article

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