Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 =)

like image 828
Михаил Николашин Avatar asked Apr 01 '16 15:04

Михаил Николашин


1 Answers

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).

like image 158
Eike Pierstorff Avatar answered Sep 17 '22 12:09

Eike Pierstorff