Reputation: 63
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 =)
Upvotes: 6
Views: 6679
Reputation: 121
You can't send the array native but you could encode your properties in a string such as e.g. if you wanted to track whether up to 26 different properties were true or false, you could index each property with a letter of the alphabet then idempotent add that letter to your dimension string to set the property true, or idempotent delete that letter to set it false.
Then in Analytics you could filter reports according to presence or absence of the letter in the custom dimension.
That's a really simple encoding but you can easily get to way more than 2^26 possible values by using a different encoding such as e.g. having a three-letter string made up of two characters and a spacer. That would give you scope for 2^(26^2) values or 676 independent key words provided only up to 50 were needed on any given page.
Of course you would have to use a lookup table later to interpret your reports.
Upvotes: 0
Reputation: 1
As possible workaround you may use for cycle and send custom dimensions with events.
var arrayga = ["first", "second", "third"];
var len = arrayga.length;
for (var i = 0; i < len; i++) {
ga('send', 'event', 'Produkt', 'Sent', {
'dimesion1': arrayga[i]
}
This will work only for hit type custom dimenssion.
Upvotes: 0
Reputation: 32760
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).
Upvotes: 11