Javascript Question

How to send an array as google analytics custom dimension?

Using Analytics.js

I've got 3 articles with an arrays of tags, example: Rihanna, Beyonce and JayZ

And I need to determine which one of them is more popular for users.

In first article i've got only JayZ tag
and send the demension as:

ga('set', {
'dimension1': 'JayZ',

ga('send', 'pageview');

But the second and the third has an arrays [Rihanna, Beyonce] and [Beyonce, JayZ]

How to send this tags as separete parametres to one custom dimension?

This send just a simple string of all tags

ga('set', {
'dimension1': array,

This send only last parametr:

ga('send', 'pageview' {'dimension1': 'JayZ', 'dimension1': 'Beyonce'});

I can't use sepearate dimenssions for every tag, i've got 10 000 tags on my website =)

Answer Source

You cannot. GA does not accept arrays, it only takes strings as custom dimensions.

Of course you could join your arrays into strings ( myarray.join(";") ) , but that still might not help you since a custom dimension can only have 150 bytes (and you could not sort/filter by individual tags).