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:
And also looked at this documentation from Google:
https://developers.google.com/analytics/devguides/collection/gtagjs/custom-dims-mets
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.