Google Analytics analytics.js Anonymous Score Reporting

86 Views Asked by At

So I'm trying to set up Google Analytics for my web game. I need to send over a score and I've gotten that working, but the problem is when I test the game and check my custom report the next day then I see only one entry and it seems like it just added up all the scores and put them into one entry. I believe the solution is to use dimensions to make multiple entries. Here's what I have right now for sending over data to analytics.

var rid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
    var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
    return v.toString(16);
});

// send over relevant analytics data to Google Analytics
ga('set', 'dimension1', rid);
ga('set', 'metric1', NJ.analytics.blocksCleared);
ga('send', 'event', 'Game', 'end', 'Game Session Data');

I'm not sure if this is the correct solution and it might also create duplicate data since I'm just generating a random string. Can someone confirm that this is how you generate rows of custom variables in analytics.js and suggest a better method of generating unique anonymous users for analytics.js?

1

There are 1 best solutions below

0
On

Having a single row for each score is not very helpful by itself. If you still want to do it though, custom dimensions is the way to go. I am not sure if that is going to provide the data you need though.

The primary question is: What do you want to do with the data you are collecting? If you are interested in the average of scores, you can look at event value field.

Custom metrics by definition are aggregates and will result in a single value over a period.