setVisitorId overriden last minute?

Hi,

I’m not sure if this is a bug so I’ll ask it here.

I’m struggling to get the setVisitorId function working as I’d expect it. My case is the following:

I track a native Android application that at some point switches to a webview. I want to track the user as a single visitor. In order to do that I have a cookie that is exchanged between native implementation and webview which then in turn sets the visitor id in the Android SDK or the PHP web page respectively.

I can see the calls made to matomo and they show the right visitor id for both calls. However, in my visitors log the webview visitors get a different visitor id. If I repeat this the visitor id is getting generated over and over again for the webview but visits get stacked in the same unique visitor consecutively. This happens despite calling setVisitorId on the web page.

Oddly enough this works on iOS. I used the piwik-3.0.4 and now matomo-4.1.2 version of the Piwik/Matomo Android SDK with no spotted difference. Matomo itself is running 3.14.0.

Is it possible something is wrong with the setVisitorId process and the ID is being regenerated because of missing flags like userId (I set this to null in Android)? How is the visitor id being changed afterwards and yet still being recognized as the same visitor? What am I missing?

I’d be happy if anyone could help as I don’t know what else I can do to get this working.

Thanks and best regards