How to track a mobile app with HTTP requests?



It is quite unusual to track a mobile app with HTTP trackers. But we never know. The typical use case is the one shown in the video above. For example when you are dealing with a mobile app back end development where you cannot embed any Java code and/or JavaScript code.
This is where the image tracker will start to be handy. In fact, this tracker is doing nothing more than using the API of Matomo in order to send HTTP requests which contain the data that we would like to send.
The advantage of using it in a platform such as App Inventor 2 is that you can use the variables in order to make the data dynamic within the requests.
Ok, let's simply study how the Matomo HTTP tracking API is working.
Here is an example:
http://localhost/mat311/matomo/matomo.php?idsite=1&rec=1
As you can see it is composed of a basic URL:
http://localhost/mat311/matomo/matomo.php (which is our tracker).
and two parameters (the one after the ?):
idsite and rec. Both have two values, one for each, 1 for idsite, one for rec.
So this full URL http://localhost/mat311/matomo/matomo.php?idsite=1&rec=1 means that we want to record something within Matomo. Typically if you copy/paste this URL within your browser, you will see that in Matomo:
Your first mobile interaction
At this given step, you almost got it. What is left, is nothing more than the additional parameters that you will add in your request.
So to say if you write your request this way:
http://localhost/mat311/matomo/matomo.php?idsite=1&rec=1&action_name=home-screen
You will get this:
You just learnt how to send a screen view in Matomo, congrats
the list of all the other parameters that you can add are listed within the official documentation of Matomo at https://developer.matomo.org/api-reference/tracking-api

Advantages of the HTTP request method

  • Easy to learn.

Drawbacks of the HTTP request method

  • If you use it like this the battery life of the mobile users is going to decrease significantly. You need a way to store those requests and send them only when appropriate.
  • You need to custom each HTTP request one by one which is a pain.



Last modified: Saturday, 28 December 2019, 3:05 PM