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

Adding custom dimension to track Confluence space key in Google Analytics

I'm using Google Analytics to track a Confluence site (by inserting the tag in custom HTML, not with a plugin). I'd like to pass the space key to Google Analytics so I can track spaces separately. 

Here's the code I tried. The first part does seem to map dimension2 to Confluence_Space_Key (I see it listed under Custom Dimensions in Google Analytics). But the second part to send an event with the space key doesn't seem to be working (there is no data for Confluence_Space_Key). If anyone can spot the problem, I'd really appreciate the help!

 

// Maps 'dimension2' to 'Confluence_Space_Key'.
gtag('config', 'UA-XXXXXXXXX-Y',

{
'custom_map': {'dimension2': 'Confluence_Space_Key'}
});

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

</script>

 

In case it's helpful, I started with this community post: 

https://community.atlassian.com/t5/Confluence-questions/Google-Analytics-track-one-space/qaq-p/595032

And also looked at this documentation from Google:

https://developers.google.com/analytics/devguides/collection/gtagjs/custom-dims-mets

 

 

0 answers

Suggest an answer

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

What project did you transition or start on Confluence with the shift to remote work?

It’s been great to hear from fellow users over the last few weeks about the best tips and fun moments you’ve had working on Confluence since the transition to working remote. I’d love to keep the c...

159 views 3 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