Analytics
3.5K members online now
3.5K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

Include an array object in Custom Dimension

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hello all,

 

I was wondering if someone could help me with the code that I would need to add to the JS code of my website to use a custom dimension that allows me to return part of an array.

 

CMS.user = {"accounts":[{"type":"Admin","default":"","tags":[],"isShared":false}, {"type":"Manager","default":"","tags":[],"isShared":false}]};

 

All that I would want to see in Google Analytics is 'Admin' and 'Manager' (or any other user types recorded against a user).

 

I tried ga('set', 'dimension1', CMS.user.accounts[0]); and a few other variations but I only get to have [object Object] displayed in Google Analytics.

 

If someone could let me know how I would need to modify the ga set function, I would really appreciate it.

 

Many thanks,

Sandra

 

 

1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Sandra W
February 2016

Re: Include an array object in Custom Dimension

Top Contributor
# 2
Top Contributor
Hi,

did you try CMS.user.accounts[0].type ?
--
To make bad day worse, spend it wishing for the impossible

Antti Nylund, Google Analytics Top Contributor
Did my answer solve your issue? If yes, please mark it as the ‘Best Answer.’ Otherwise keep on asking.

View solution in original post

Marked as Best Answer.
Solution
Accepted by topic author Sandra W
February 2016

Re: Include an array object in Custom Dimension

Top Contributor
# 2
Top Contributor
Hi,

did you try CMS.user.accounts[0].type ?
--
To make bad day worse, spend it wishing for the impossible

Antti Nylund, Google Analytics Top Contributor
Did my answer solve your issue? If yes, please mark it as the ‘Best Answer.’ Otherwise keep on asking.

Re: Include an array object in Custom Dimension

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Hi Antti, I must have forgotten the dot between [0] and type. It is now working, thanks so much! Smiley Happy Have a nice day. Kind regards, Sandra