Repository navigation
Replies: 1 comment
|
The important distinction is whether an htmx swap represents a real navigation or only updates a fragment. For If you use an older/self-hosted tracker build or deliberately disable automatic pageviews, htmx exposes precise history events: function trackHtmxPageview() {
// The URL has already been updated when these events fire.
if (window.plausible) plausible('pageview');
if (window.umami) umami.track();
}
document.body.addEventListener('htmx:pushedIntoHistory', trackHtmxPageview);
document.body.addEventListener('htmx:replacedInHistory', trackHtmxPageview);Use this manual version only with automatic pageviews disabled:
I would not attach a pageview handler globally to document.body.addEventListener('htmx:afterSettle', event => {
if (event.detail.target.id === 'report-panel') {
plausible?.('Report Viewed');
umami?.track('report-viewed');
}
});So the practical setup is:
References: htmx history events, Plausible manual pageviews, and Umami SPA tracking. |
Uh oh!
There was an error while loading. Please reload this page.
Has anyone managed to get a working client-side setup? (Plausible or Umami)
How to correctly hook into htmx lifecycle and report "views/screens"?
All reactions