Goal tracking from inside an Android native app

I’m trying to use a Goal to track login requests through my Android app.

I have an PHP API running with json support. There is an API method in the API to validate users, I want to add every validation request to a Goalwith the tracking API but for some reason it does not work properly.

Basically every user that tries to login should be added to the goal.

Can Piwik be used to do that?

You can use the tracking API documented in Tracking API - Analytics Platform - Matomo
and use the function doTrackGoal from http://qa.piwik.org:8080/phpdocs/PiwikTracker/PiwikTracker.html

Well as indicated in my email that is exactly what I use but when using it only registers one goal. When I run the script multiple times it does not add up.

Does the goal tracking do something with unique visitor? All my users go through the same API php file but I guess that should work.

Very weird.

Goals are only triggered once per visit: Track Goals and Measure Conversions - Analytics Platform - Matomo

Thanks for your reply, I understand that. The question is what is a visit when you have the following scenario:

  • central API hosted on one server (one IP);
  • Android user go through this API and it this API also does a goal call.

I think Piwik sees all the users as one visit because there is the central API and Piwik does simply see one IP address, namely that of the server where the API is hosted. I also notice you cannot pass for example a country etc. so it stores one country, namely thet country where the script is hosted.

On the Piwik site there is a claim it works but I have a lof of doubts if it is usable from an Android app. I have used the Mixpanel product and that has no issues because it does not have the visits problem because the app determines what gets stored in terms of clicks etc.

Could you explain a little more in your answers and take my scenario as a sample? I don’t think Piwik is usable in this scenario (and this scenario is what most mobile devs use).

The fact that all the same IP is indeed a bug, see ticket: Tracker API improvements : enable set IP and set server date & time · Issue #1553 · matomo-org/matomo · GitHub
this will be implemented in Piwik 1.3 in a few weeks time

Hmm, not sure if IP based is going to work for Android. Getting the IP address inside an Android device isn’t that easy and it probably asks the user to give much more privileges during install.

Could you explain a little more on the proposed solution how this would tackle the goals problem from inside an Android application?


I was assuming you could get the IP in an Android app. Otherwise, you can also create a fake IP somehow, caching it locally in Android. but you still need to wait for thefeature to be built in piwik