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 163 forks source link

Merging app and WebView visits #289

Closed hannahcx closed 2 years ago

hannahcx commented 4 years ago

iOS when tracking pages seems to work correctly, telling me how long I spent in app; however, android tells me I spent 1s in app no matter how long I spent clicking through pages. Can you help?

d4rken commented 4 years ago

Time spent on a page is calculated server-side, from one view event to the next: https://matomo.org/faq/how-to/faq_21158/

hannahcx commented 4 years ago

No, as in it doesn't work :) not a question this is a bug! For android. No matter how long I spend it app the UI always registers as 1 second time spent in app.

d4rken commented 4 years ago

It works for me :tm: :sweat_smile:. Please share a minimal sample project to reproduce the bug.

hannahcx commented 4 years ago

I think the issue is that we use webviews inside the app, but the webviews are not registering as the same session. Any work around for this?

d4rken commented 4 years ago

That's probably it. I'm not sure if you can set the same IDs between both. I have never tried that.

You could track manually tracking pageviews by hooking into WebView callbacks.

hannahcx commented 4 years ago

Yes, we've done that now, and this will allow us to capture time in app and also pages viewed; however, for more complex functionality like "clicks" and "errors seen" this will be too tricky for us to capture via webview callbacks without lots of work, so we were hoping to keep webview and app code separate but have them register as the same session in the Matamo UI.

d4rken commented 4 years ago

That's not a use-case I've explored. You'd probably need to make sure the same IDs are used. I'm not familiar with the JavaScript tracker. You'll have to dive into the code yourself.

hannahcx commented 4 years ago

Same Id's used, but registered as two different sessions. Thanks anyway - needs to be resolved in the future because this is one reason why we are moving all of our apps to firebase in the future, because they handle this use case.

peterbo commented 4 years ago

This is probably due to https://github.com/matomo-org/matomo/issues/15593 - which should be fixed with the next version.

hannahcx commented 4 years ago

Ah yes, thank you, it's because of the "two sessions for a unique ID" that the app session (native pages) are registered as only being in the app for one second - if this is resolved then there potentially will be no issue, and we won't have to move to firebase!