mirror of
https://github.com/plausible/analytics.git
synced 2025-03-14 10:06:38 +00:00
Trigger pageviews on pages loaded from bfcache (#4656)
* trigger pageview on pageshow with event.persisted * update _tracking.html to do the same
This commit is contained in:
@ -32,6 +32,13 @@
|
||||
}
|
||||
|
||||
plausible('pageview', defaultEventOptions)
|
||||
|
||||
window.addEventListener('pageshow', function(event) {
|
||||
if (event.persisted) {
|
||||
// Page was restored from bfcache - trigger a pageview
|
||||
plausible('pageview', defaultEventOptions);
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
@ -231,6 +231,15 @@
|
||||
} else {
|
||||
page()
|
||||
}
|
||||
|
||||
{{#if pageleave}}
|
||||
window.addEventListener('pageshow', function(event) {
|
||||
if (event.persisted) {
|
||||
// Page was restored from bfcache - trigger a pageview
|
||||
page();
|
||||
}
|
||||
})
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
|
||||
{{#if (any outbound_links file_downloads tagged_events)}}
|
||||
|
Reference in New Issue
Block a user