Where/How to add macro (code) being available on EVERY Confluence page?

I've created a small user macro which return the page id: $content.getIdAsString()
Works quite well to add this to a page when in being in edit mode.

How, better where, to place this line to get this line automatically added (and non removalbe by users) to all confluence pages (in header or footer)?

Same question for external macros: I would like to have "Viewtracker" at bottom of every page.

I've tested "Admin > Layouts > Main layout", but did not find the right line where to add my code.

Did only get the macro-code renderdered as text (not executed) and often overlapping to the existing texts.


PS: Unfortunately Atlassian "lost" all my karma points when merging twom accounts...

6 answers

1 accepted

3 votes
Accepted answer

Hi! You can render macros here the same way you would use to render macros inside macros:

#set($globalHelper = $action.getHelper())

There's even a $page variable available in the page layout, so you could even use this one directly instead of your macro code.

Regarding the "where" - look through the code of the "page" layout (and blog, if you need that too) to find your desired position, it's pretty linear and quite easy to understand.

For the documentation theme, try to insert the viewtracker macro via "Space Admin" => "Themes" => "Configure Theme" into "Messages" header or footer.

Put in a support ticket for the karma points problem - the same thing happened to me and they fixed it. :)

Thanks Oliver..we are using the default theme where this options are n/a.

I still suppose adding "code" to "Admin > Layouts > Main layout" will help, but what and where?


This works, thanks!

I need to change the position, though.

The pageid and TinyURL shall be presented after the page breadcrump list

Pages / Level 1 / level 2 / instruction (PageID: xxxxx, URL: yyyyy)

I've read a lot but still am confused (due to missing knowledge) what constructs to use:

#set($globalHelper = $action.getHelper())


or $sitemeshPage.getProperty("page.pageID") or similar

or ${page.id}

or {page-info:tinyurl}

or AJS.$("#pageId").val()

or ...

Nothing really works...

Thanks /Markus

Hi, if you want it to be part of the breadcrumb navigation, you need to update the breadcrumbs.vm in C:\Program Files\Atlassian\Confluence\confluence\breadcrumbs.vm. I've tested it with v5 of confluence but should be the same for v4.

At the end of the document look for

##        </li>


You can just add another <li> element between #end and <ol>. $page.id is working here, so

##        &lt;/li&gt;


results in

(no restart required for this)

Thanks a lot Superuschi (Daniela? :-).

This works very well! Do you happen do know where to find more page.xxx properties; e.g. the tinyurl?

Greetings from DU to OB /Markus

On admin- and profile-pages unfortunately the "$page.id" does not get rendered but is shown as plain text.

Do these pages do not have a unique id?

Regards /Markus

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 24, 2018 in Confluence

Atlassian Research opportunity with Confluence templates

Do you use templates with Confluence? Take part in a remote 1-hr workshop. You'll receive USD $100 for your time!   We're looking for people to participate in a   remote 1-hr workshop...

1,521 views 25 14
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