Recently, I've been working on setting up Google Analytics for tracking my web game. Everything seems to be working fine, except for one issue - when I check my custom report the next day after testing the game, I notice that all the scores have been combined into one entry. I suspect that using dimensions can solve this problem by creating multiple entries. Below is the code I am currently using to send data to Google 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);
});
// sending relevant data to Google Analytics
ga('set', 'dimension1', rid);
ga('set', 'metric1', NJ.analytics.blocksCleared);
ga('send', 'event', 'Game', 'end', 'Game Session Data');
I am unsure if this approach is correct, and I am concerned about potential duplicate data due to the random string generation. Can anyone confirm if this method is suitable for generating custom variables in analytics.js and provide suggestions for a more effective way to generate unique anonymous users for analytics.js?