Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Piwik tracking in an android application

I want to do data analytics for my android application using Piwik.

In Piwik's documentation, they suggest using GitHub.

I got the Piwik API and download the following file:

https://github.com/piwik/piwik-java-tracking

which I don't know how to use.

What are the steps needed to get the data analysis using the Piwik working?

What should I do next?

like image 963
Madhan Devan Avatar asked Oct 01 '22 13:10

Madhan Devan


1 Answers

I also would like to implement piwik tracking in my android app.

This is what I understood so far:

  1. Unlike for iOS/MacOS applications, there is currently no SDK to help us out. Piwik developers have a ticket opened in their bugtracker about this, which shows they're aware of the issue and willing to improve the situation, but it will take some time before this android tracking SDK is released.

  2. At the moment, the Piwik team encourages android and Java developers to use the piwik-java-tracking library you mentioned. This is basically just a java wrapper for the web tracking API reference, which helps you to generate Tracking Request URLs to send to your Piwik instance.

This piwik-java-tracking project lacks documentation (there is none that I know of in Github), but there is javadoc in the java files.

Basically what you need to do to track an action is to:

  1. Create a new instance of SimplePiwikTracker
  2. Feed it with whatever values and parameters you wish to track using the various setters available
  3. When you're done, get the URL using one of the methods defined in the PiwikTracker interface, depending of the type of "event" you want to track
  4. Send a request to that URL to actually track your action into you Piwik instance.

This has several drawbacks:

  • If you need bulk tracking, you'll have to figure out a way of doing so. The web tracking API reference states you can use use a HTTP POST request containing a JSON object to do it.
  • It doesn't provide any help to handle the case where user is offline. If you need to, you'll have to find a way to cache your tracking request (in an sqlite database for example) and bulk send them when the user is back online.
  • You'll need to handle possible exceptions raised by network error for the tracking request, to make tat tracking does not interfere with your app normal behavior.

Be sure to read this article too. It gives you an overview of what you need to do to get up & running.

This is what I understood so far. I may update this answer as I progress in implementing piwik tracking in my own app.

Good luck.

Edit: I just noticed that Piwik released "Piwik SDK Android". There are some instruction on how to get this working in the project's wiki.

like image 136
nstCactus Avatar answered Oct 05 '22 12:10

nstCactus