Forums

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

How can I track user data with Google Analytics?

Gary McCormick August 6, 2014

I want to remain using Universal Google Analytics outside of Confluence (rather than using a plugin).

My wiki is for employees and requires login, so I am in compliance with the User-ID policy as far as I can tell. My users login via an LDAP directory.

I'd love to be able to track who has viewed what.

I think I need to add a USER_ID to this code, but I'm not sure which one to use. I've tried global variables: $current_user_email and current_user_email

ga(‘set’, ‘&uid’, {{USER_ID}}); // Set the user ID using signed-in user_id.

Additionally, the &uid portion of the GA tracking code is throwing an error in my theme.

3 answers

2 votes
Thomas Alfred
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 27, 2014

This is not currenty possible while complying with Google Analytics terms of service.

In your example, the {{USER_ID}} variable must be set using valid JavaScript. For example like so:

var userId = 'some value'; // you need to populate this
ga('set', '&uid', userId);

David Simpson discusses how to achieve this (and importantly how not to achieve this) in Identifying your users in Google Analytics while complying with section 7 of the terms of service.

He is currently suspended from Atlassian Answers, so perhaps ask your question out in the open at Stack Overflow instead.

Also, don't add this into your theme. Stick it in the Custom HTML instead.

2 votes
Branno
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 12, 2014
0 votes
Serhii Riabovil August 25, 2017

The following code works for me (userId represented by 32-digits key):

ga('create', 'UA-xxxxxxxx-1', 'auto', {
userId:  '$userAccessor.getUserIfAvailable($req.remoteUser).getKey()'
});

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events