Search code examples
google-analyticsgoogle-analytics-apiweb-analyticsuser-tracking

Change Google Analytics' uniqueness criteria


I am currently using Google Analytics in my Application, where most of the pages are after login. I found an issue with GA, around unique user count. The problem is that if the same user logs in from different machines, then he is tracked as a new user, and if two users login from the same machine, it is tracked as one user. I would like to change the uniqueness algorithm for GA, to use my own accountIds as the unique key. Is this possible? If not, how can I address this problem?


Solution

  • You can do that with Universal Analytics, the new version of GA by generating a unqiue client id per logged in user and passing it to the tracker when it's being created.

    ga('create', 'UA-XXXX-Y', {
      'clientId': '35009a79-1a05-49d7-b876-2b884d0f825b'
    });
    

    (this is an example from Google UA Documentation, so while I haven't tested this yet I guess it should work).