Search Unity

Identifying New Users in WebGL

Discussion in 'Unity Analytics' started by nrvllrgrs, Aug 10, 2020.

  1. nrvllrgrs

    nrvllrgrs

    Joined:
    Jan 12, 2010
    Posts:
    62
    How are new users identified on a WebGL build? Currently it seems as though every session always registers as a new user, which makes for garbage data. Is there a way to ensure that new user actually means new user?
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  3. nrvllrgrs

    nrvllrgrs

    Joined:
    Jan 12, 2010
    Posts:
    62
    At the moment, I am letting Unity Analytics identify new users. Previously, I was using standalone builds and Unity Analytics successfully identified new users (or at least was seemingly successful). When I started making WebGL builds, the new users count grew with every new session, even from the same computer.
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Are you testing from the Editor via Build and Run? If so, it's launching a new web server each time. If you deploy to a public IP, it should work. Another test would be to allow users on your local area network to do the same test you just mentioned, with a single running instance from Unity.
     
  5. Yiorgos

    Yiorgos

    Joined:
    Jun 5, 2013
    Posts:
    26
    I came up with a solution that's surely not optimal or bulletproof, but it suits my casual project, so I thought I'd share it. I'm concatenating a few SystemInfo values, and then creating an MD5 hash out of them. Something like this:
    Code (CSharp):
    1. string playerId = Utils.ComputeMD5Hash(SystemInfo.deviceName + SystemInfo.deviceModel + SystemInfo.deviceType + SystemInfo.graphicsDeviceType + SystemInfo.graphicsDeviceID);
    (Utils.ComputeMD5Hash is a custom method, you can find many of them online)
     
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    How do you use this playerID?
     
  7. Yiorgos

    Yiorgos

    Joined:
    Jun 5, 2013
    Posts:
    26
    The playerId is used in a database where I'm storing players' scores, settings etc.

    I practically need a means to identify each device without having to ask for credentials.On my android build this is done via SystemInfo.deviceUniqueIdentifier, so I wanted something similar for my webGL build.

    But as I said my approach was rough, so eventually I reconsidered, and now I'm pinging a web server for a session cookie and a unique uuid. Which again isn't 100% optimal (if the session expires, a new uuid will be generated and all previous data is practically lost), but it seems better.

    The ideal solution would be a webGL equivalent of deviceUniqueIdentifier, but that's not available.
     
  8. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Sorry I meant, how are you using the playerID in your Analytics calls. And if you are using a session and unique UUID, how does this persist for the user? If they use a different browser (or a different device, for non-webGL), how does the user know about this this value in order to log in again? I should add, webGL support is limited at this time, both in legacy Analytics and in the Analytics beta. We are looking at this issue currently to determine our future level of support for webGL.
     
  9. Yiorgos

    Yiorgos

    Joined:
    Jun 5, 2013
    Posts:
    26
    You are right, the id is browser/device/session specific, but that's ok with my approach, in fact that's exactly what I want.

    But no, I don't use this playerId for analytics, just in my database. I found this thread googling for webGL user identification and didn't notice it is posted under "Unity Analytics" until now. :(

    Feel free to delete my answers if they 're misleading. Sorry about that.