matomo-org / matomo-sdk-ios

Matomo iOS, tvOS and macOS SDK: a Matomo tracker written in Swift
MIT License
388 stars 164 forks source link

Difference UserID en VisitorID #407

Closed wiekep closed 1 year ago

wiekep commented 2 years ago

Hi, at our company we´re using a native SDK for our app application. While tracking and analyzing the raw data from the Matomo API, we analyzed two scenario´s; one in which the UserID has multiple visitor ID´s and one in which the visitorId's has multiple UserID's. Now we were wondering, what is the different between the UserID and VisitorID? And which one do we need to track the unique users visiting our app our a specific page?

Like to hear from you, Wieke

brototyp commented 2 years ago

Hi @wiekep,

thanks for your question. The visitorID is an identifier generated upon first initialization of the SDK and will not be changed after that. It is persisted in the UserDefaults. This value can in theory be overridden by setting the forcedVisitorId but unless you do that it shouldn't change. The userId is a way to identify users across multiple devices and installations. It will only be set if you set the userId manually. A few more details can be found in the Readme.

Does this help?

Kingamattack commented 2 years ago

If I don't set my userId, does the SDK generate one by default? I heard this is the default behavior on Android but I don't know for iOS

brototyp commented 2 years ago

No, the SDK doesn't generate a userId itself but it does generate a visitorId.