TLDR: I use a unique key shared between UI models and DTOs to reference and retrieve necessary data needed for analytics.
Longer version:
I think I understand what you mean, I had the same doubt at one point. I keep my analytics trigger point in the ViewModel (Presentation Layer), as these analytics are usually based on user actions on the UI, which are passed to the ViewModel to execute business logic.
Often, our analytics require details that are not part of the UI but of data layer objects (DTOs). I used to dump such data into the UI model and retrieve it in the ViewModel when the user triggered an action. However, this approach made my UI models unnecessarily bloated.
Nowadays, I keep a unique key in both my UI model and DTO. This way, I can reference the UI model when an event is triggered. In the ViewModel, I populate my analytics with relevant details from the UI model and use the key to get the corresponding data from the DTO. This approach keeps my UI models clean, and maintaining a key is straightforward.
Still trying to find a better approach though 😅.