I have a complex web application written in Yii2 / PHP. How can I track application usage for users which are signed in?
There are tracking tools as GA (Google analytics) or Piwik analytics with good Yii2 extensions for integration into an application.
Since these tools are intended for public websites they are not perfect for in-application usage tracking:
My question is which tracking strategy fits best for an Yii2 application and which Yii2 extensions do you recommended?
I presonally would start with request logging (for instance by extending the default Yii2 request class, and using the extension in your application) by saving all the relevant data to you to the database, and adding a user id to it, and just build from there.
That way you dont have to rely on GA that much, as you already have all the info on the user
Google Analytics would be a good bet based on the information you provided.
GA has a server-to-server protocol, called GA measurement protocol.
It also has a wonderful concept of the "User". The User is central to GA functionality. If you're not tracking users with GA, then you're really not using the tool as intended
The user by default is assigned by a "client id". For web, this is stored in a cookie, for mobile it is stored in application storage. For server-to-server, your app simply keeps track of the IP address and "client-id" of the session/user and GA will take care of the rest.
Also, GA lets you override the client id with a "user id" specific to your application. This lets you track users even as they login from different devices. https://support.google.com/analytics/answer/3123662?hl=en
GA also gives you fine grained control over how to handle the "referrer" information. It appears to meet all your criteria!