It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

google analytics on confluence pages

Can we gather analytics (via Google) on Confluence usage by pasting the javascript below into the page template header for any pages we want to track.

Can I do this within Confluence?

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-35048994-1']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);


7 answers

1 accepted

8 votes
Answer accepted

Yes, you can perform it within Confluence. Please, refer to the following path:

Browse > Confluence Admin > 'Look and Feel' - Custom HTML > Edit

Through this page, insert your javascript where you want. In this case, at 'end of the HEAD'.

Kind Regards

Interesting.. i will try this way.

Thanks, Srinivas

Does this need to have the AJS.toInit included before the function in the JavaScript to make it work in Confluence?

Does this work on a space level?


I am only interested in tracking the one space not all.

You can apply it universally in Confluence, then within Analytics you can set up a view that shows only the analytics for a particular space by providing the URL.

Thanks all!

  1. Does this apply to Confluence Cloud?
  2. Should this be done manually with all Confluence URLs that need to be tracked?



@federico This is for Confluence Server only, where you can add custom JavaScript.

For Confluence Cloud, this is not possible, so you'll need to use an add-on such as:

Like Dave Liao -Cprime- likes this

I just downloaded your product, working fine so far! Thanks, David.

Like David Simpson likes this

Also you can check this plugin:

This plugin displays reports for an external Confluence website, or a particular space...please check if this plugin suits for you.

Yes. I already tried that. This requires a license though :)

Go to:

  • Global Administration
  • Custom HTML
  • At the end of HEAD
  • Paste your script.

It works pretty well, I'm sure ;)

Hi Srinivas, Please tick the right answer if it worked for you. Thanks!


We have enabled google analytics and I would like to get metrics (page views and duration etc) on a specific confluence page and email to a particular user group.

Note: I'm not looking for a paid solution. The videos out there are old or specific to paid solution.

Thanks in advance


Hi! I want to do this only for one space. I go to Browse>Space Admin>Look and Feel>Themes>Configure theme>Messages>Header and enter the script there using the {html} macro (we're on conf 3.5).

However, Conf removes the leading bracket from <script>, and removes the closing tag </script> altogether. I even tried making a custom macro {html-script}, but the result is the same. Adding the script to an individual page works ok.

Please help!

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in United States

Live! - Austin ACE -- Summer BASH 2019

Hey Austin! Come join us for our 2019 Atlassian Community Summer BASH as we transition ourselves into party status! Bring an attachment, log a great time, and collaborate with new friends as we celeb...

12 views 0 0
View post

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you