Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  4. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Change Analytics Unique Identifier?

Discussion in 'Unity Analytics' started by Greyborn, Aug 25, 2018.

  1. Greyborn

    Greyborn

    Joined:
    May 26, 2016
    Posts:
    14
    Hello, I have been trying to figure out a way to easily test our funnel logic by doing multiple playthroughs of our game on the same system. Is there an easy way to change my dev system's identifier so Unity Analytics will see it as a new user/machine when I reset our game and do another playthrough?

    I've seen this: https://docs.unity3d.com/ScriptReference/Analytics.Analytics.SetUserId.html

    ...but the documentation for its use (and even what exactly you pass for "userId") is a bit... sparse ;) Can I just pass a random int?

    Is the unique id something I change in Windows 10 (and is that what Unity is using for its ID)?

    Thank you for any suggestions!
     
    Last edited: Aug 25, 2018
  2. Greyborn

    Greyborn

    Joined:
    May 26, 2016
    Posts:
    14
    Also, a related question - what c# code can I use to print the current unique id Analytics is using for my system? While I see there is a SetUserId I don't see any kind of "GetUserId". Thanks again!
     
  3. Greyborn

    Greyborn

    Joined:
    May 26, 2016
    Posts:
    14
    Anyone from the Unity Analytics team that could help us out here?
     
  4. Benvictus

    Benvictus

    Unity Technologies

    Joined:
    Sep 12, 2013
    Posts:
    86
    @Greyborn,

    I would suggest doing this example to change your sessionId for your funnel tests:

    1. Fire the funnel.
    2. Call `PlayerPrefs.DeleteKey("unity.cloud_userid_h2665564582");`
    3. Restart the editor/build
    4. Repeat.

    Restarting will re-create the key "unity.cloud_userid_h2665564582" and also assign the new value to
    AnalyticsSessionInfo.userId
    . I found this post useful as it shows a list of keys for playerPrefs.

    Note: Different Unity versions might have different player pref keys. I'm using 2018.1.5f1 for my test.

    We will be deprecating
    Analytics.SetUserId()
    in the next version of Unity. This is to help developers to comply to GDPR better by avoiding the sending of analytics events that may contain personal data. Before the deprecation you could essentially submit your own userID to help identify where the events are coming from and identify the players.

    If you want to print the userId to the console then you can use
    AnalyticsSessionInfo.userId
    or
    print(PlayerPrefs.GetString("unity.cloud_userid_h2665564582"));
    .

    Hope this helps!
     
    Greyborn likes this.
  5. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    2,213
    An app reinstall would be considered a new user.
     
    Greyborn likes this.
  6. Greyborn

    Greyborn

    Joined:
    May 26, 2016
    Posts:
    14
    Thank you both, very helpful info!