Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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 - track one space


We use Google Analytics for our whole Confluence instance (just one .js tag putin the custom html)

If I want to track just one space.  I went ot behaviour - all pages and did a search for the space key - but I think that just takes me to the main page.  How do I track all visits to one space?


Mr. V

1 answer

1 accepted

Add a custom dimension which tracks the space key, then in Google Analytics you can simply filter on the space key to see the results for just that space.

See my blogpost - Tracking Atlassian Confluence usage with Google Analytics - for how to do this, or copy the code below:

  // Standard Google Universal Analytics code
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    ga('create', 'UA-XXXX-Y', 'auto');
    // Add a page-level custom variable to record the space-key
    if (typeof AJS.params.spaceKey === 'string') {
      ga('set', 'dimension1', AJS.params.spaceKey); // Set a `spaceKey` dimension at page level
    ga('send', 'pageview');


Wow!  That is fantastic!

We do not use the Google Analytics Plugin, instead, we just added the tracking code to the Custom HTML.

Will this still work?

Substitute my GA code instead UA-XXXX-Y?



I don't have the Google Analytics Plugin - will I still be able to get this info easily?

For this part:

"You now have a Custom Dimension named Confluence Space Key which is available for use within the Google Analytics interface. Next, you’ll need to populate this custom dimension with some data. "

I see this:

var dimensionValue = 'SOME_DIMENSION_VALUE';
ga('set', 'dimension1', dimensionValue);

dimensionValue is the space key?

And where does this code go?  In my custom HTML?

Sorry for the noob questions.





There is a new and recommended Global Site Tag (gtag.js) tracking code as follows.
What's the respective way of adding Space tracking to a custom dimension? Thank you

<!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src=""></script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments)};
gtag('js', new Date());

gtag('config', 'UA-XXXX');


@web service, I just came across this article. Does this help answer your question? 

Custom dimensions and metrics with gtag.js

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src=""></script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

// Maps 'dimension1' to 'Confluence_Space_Key'.
gtag('config', 'UA-XXXXXXXXX-Y', {
'custom_map': {'dimension1': 'Confluence_Space_Key'}

// Sends an event that passes 'Confluence_Space_Key' as a parameter.
if (typeof AJS.params.spaceKey === 'string') {
gtag('event', 'pageview', {'Confluence_Space_Key': AJS.params.spaceKey});


 I'm working through the same issue and trying to piece together the code, though without really understanding what I'm looking at.  

@David Simpson _David Simpson Apps_, not sure if you can confirm if the above would work for gtag.js, but your blog posts have been so helpful and I'd love to someone more knowledgeable than I am take a look at this!

I gather this won't work for Confluence cloud - anyone?

Unless there is somewhere else to put the code, 'custom html' not seeming to be available in Admin?

Helen, you can use Google Analytics in Confluence on Cloud, then use the drilldown report in Google Analytics to look at analytics on one space.

@Helen Gosper

Just a note, Atlassian limits the data (location and page views) we can see in Google Analytics about public (anonymous, unauthenticated) users. My thought is that they are pushing Confluence users to purchase Premium to get Analytics which includes page views and authenticated user activity.

Suggest an answer

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

What do you think is the most *delightful* Confluence feature? Comment for a prize!

- Create your own custom emoji 🔥 - "Shake for Feedback" on mobile 📱 - An endless supply of GIFs via GIPHY 🤩 Is there anything quite as nice as a pleasant surprise? Comment below with what...

383 views 23 8
Join discussion

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