matomo-org / matomo-sdk-android

SDK for Android to measure your apps with Matomo. Works on Android phones, tablets, Fire TV sticks, and more!
BSD 3-Clause "New" or "Revised" License
388 stars 162 forks source link

setUserId does not work #162

Closed mico81 closed 7 years ago

mico81 commented 7 years ago

Hello,

I have an issue for adding an UserId to the Piwik Tracker. I don't want to use the User IP because I want to see unique visitor stats on a month, but a same user can use different IP along the month. That's why I want to set an Unique UUID, that I generate and save on the first launch of the application.

That's my code when I declare the piwik tracker.

piwikTracker = Piwik.getInstance(this).newTracker(new TrackerConfig("myserverurl.com", 1, "tracker")); if(userUUID != null && !userUUID.isEmpty()){ piwikTracker.setUserId("myUniqueVisitorUUID");}

The track has the UUID, but on my Piwik Dashboard, User are still sort by IP address... and I don't see my User UUID on the session information panel.

Can you help me on that please ?

Thx a lot !

d4rken commented 7 years ago

That's why I want to set an Unique UUID, that I generate and save on the first launch of the application.

Piwik already does that by default, see here

The track has the UUID, but on my Piwik Dashboard, User are still sort by IP address... and I don't see my User UUID on the session information panel.

I don't know what the "session information panel" is, do you mean "visitors in real-time"?

mico81 commented 7 years ago

I don't know what the "session information panel" is, do you mean "visitors in real-time"?

Sorry, yeah I mean that. So why can't I see Unique visitors for a month ? I mean, for now, unique visitors are working when I check for a day. But for a month, I get wrong value : for exemple, I have 27 visitor in Monday, and 27 in Tuesday (they are the same), if i want to get the unique visitors for those two days, piwik return me 54 (he's adding each daily total).

d4rken commented 7 years ago

The real time visitor display just shows entries by time.

Your UUID should be visible in each entry, if you click the UUID you should see all visits from that user.

snip

The unique visitors should be visible in the "Visitor Overview" panel:

visits

Unless you think there is a client side bug, questions regarding the webUI should be directed towards https://github.com/piwik/piwik

mico81 commented 7 years ago

Yes I see that, but Piwik still create new id while I didn't uninstall my application (uuid is present in preferences), so my phone appears for exemple in 2 uniques visitors in two days, or when I change my IP address. Then, when I attribute my own UUID, Piwik still send his own.

Is it a client side configuration ?

d4rken commented 7 years ago

If you remove your custom userId code, does this still happen? Does it only happen after a day? For it to be a bug in the Android SDK it should happen on he same day too.

Can you create a sample reproducing this?

mico81 commented 7 years ago

Yeah, I added the setUserId because it still happen without it. Here is an exemple where I launched the app 2 times, and I appear 3 times in piwik as you can see. The first time I was on my wifi, the second time I disabled it for using my mobile network (4G), so the ip address changed.

image

All of these 3 "user" are me, using different id, and I don't know why.

d4rken commented 7 years ago

Can't reproduce this.

Screenshot is from the demo app.

asd

mico81 commented 7 years ago

Hum that's weird... This is what I do : TrackHelper.track().event("application", "lifecycle").name("started").with(getTracker()); getTracker().dispatch();

The first time when getTracker() is called : piwikTracker = Piwik.getInstance(this).newTracker(new TrackerConfig("myurl", 1, "tracker"));

Then I return piwikTracker

After that, I just use TrackHelper.track().screen("/myScreen").title("myTitle").with(tracker); tracker.dispatch(); when I create some view.

d4rken commented 7 years ago

Check with the debugger or log output what the user id is: tracker.getUserId()

mico81 commented 7 years ago

I set my ID when the tracker is created. When I use this tracker, the user ID is correct. I allready check it.

d4rken commented 7 years ago

Closing due to inactivity and can't reproduce.