Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Adding custom dimension to track Confluence space key in Google Analytics

Susan Ostreicher
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 13, 2019

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
AUG Leaders

Atlassian Community Events