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?