Better mobile detection

(atrasatti) #1

I think Piwik is very interesting and I am considering to develop a small extension to better recognise mobile devices (show data in the dashboard) and also be able to better track them.

I saw a ticket on this and it’s already closed, 395[/url]. I think the current implementation solves only part of the problem. What I would like to do is integrate with [url=]DeviceAtlas a mobile device database with also knowledge of robots for the part of detection. I looked into the code and it seems to me like the changes should happen in the UserAgentParser.php, but I suspect that I’d have to replace most of it. The problem is, of course, that Tracker.php and I assume also the UI (haven’t looked into it, yet) will rely on methods that are in UserAgentParser.

I’d like to know if there is a recommended way to move forward. Since DeviceAtlas is a commercial product even though I could release the plugin as Open Source, I don’t think all users of Piwik would be very happy if my new UserAgentParser replaced completely the existing one, so what I’d like to do is leave the parsing as it is now for regular browsers, but intercept the call with my new module, get more mobile device details and then insert the code in the database.

The other part of the change would be to also provide code snippets that could be used in the website instead of the Javascript, but I don’t think this would interfere with anything else in Piwik, it would just be another page in the admin, next to the existing page for the Javascript code.

Any recommendations are welcome.

(Matthieu Aubry) #2

you can send patches for the UserAgentParser class that parses the User Agent http header to get the browser and OS the visitor is using. However we want to keep this class simple and fast, but we would accept patches to make the detection better.

(vipsoft) #3

An open source alternative would be to use Gary Keith’s browscap database. (OWA uses it and even has an updater.)

For PHP, there’s the project at Google Code Archive - Long-term storage for Google Code Project Hosting.

I imagine you could write a plugin which hooks into the core, captures the additional data, and extends existing widgets.

(atrasatti) #4

Er, not quite the answer I would have expected. If the software stays as it is, it will not be possible to integrate an alternative recognition system for browsers and devices. As I said, I understand you don’t want to be tied to a commercial product, but you can open the door.

What you say here is that my contribution would not be welcome anyway. Correct me if I’m wrong.

(vipsoft) #5

You would have to develop it as a third party plugin. Send us a patch if you create a hook in UserAgentParser.

If the UI changes are plugin specific, the plugin should provide widgets.