piwik.js: Log an error if a content interaction was tracked but no content impression #8659
Labels
c: Platform
For Matomo platform changes that aren't impacting any of our APIs but improve the core itself.
Enhancement
For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Milestone
This is related to #6270 which is about making sure to track an impression was tracked when tracking an interaction.
Background:
When tracking a content interaction, it will be only shown in the UI or reports if there was also a content impression tracked having the exact same content name, content target and content piece.
This is usually not a problem as
piwik.js
will only track an interaction if we did detect an impression (and therefore tracked it). For exampletrackAllContentImpressions
will detect all content blocks on a page and track an impression for them. This method also sets up the event listeners for content interactions. Aspiwik.js
handles the impression tracking and event listener setup we make sure to track an impression and interaction with the same values.There are some edge cases though. Eg when using
trackVisibleContentImpressions
we only track content blocks that were actually in the view part. There's a chance that we did not detect correctly an impression when it came into the view port but the user clicks on it meaning we track an interaction but no impression. A possible fix for this would be #6270. It is mainly a problem if one callstrackContentInteraction
ortrackContentInteractionNode()
manually and forgets to calltrackContentImpression
ortrackContentImpressionsWithinNode
as well or calls those methods with different values.I think we should develop both #6270 and this. I see this issue as a "safety net" to get notified in case there are edge cases etc. It is otherwise very hard to detect why a content impression is not shown in the reports.
From a technical point of view we should save all tracked content impressions in an array and when tracking a content interaction, loop over these impressions and if no impression having the same content name, piece and target was found, trigger a
console.error
(ifconsole
API is available)The text was updated successfully, but these errors were encountered: