Skip to content

[5.x] Fix track events being duplicated#1259

Merged
royduin merged 1 commit into
masterfrom
Jade-GG-patch-4
Apr 30, 2026
Merged

[5.x] Fix track events being duplicated#1259
royduin merged 1 commit into
masterfrom
Jade-GG-patch-4

Conversation

@Jade-GG
Copy link
Copy Markdown
Collaborator

@Jade-GG Jade-GG commented Apr 16, 2026

ref: RAP-1878

Two issues at play here. Firstly, this eventlistener never gets removed, which caused it to re-run on every new Turbo navigation. The requests actually piled up the more products you visited, causing things to eventually break.

Secondarily, as it turns out turbo actually loads the page twice. Once a stale "preview" version from cache, then another once the page actually loads. This is great for pagespeed, but it also means this script got executed twice on cached pages.

Luckily, we can easily check whether the page is cached by checking if data-turbo-preview is set on the documentElement.

This does beg the question... do we need to wrap anything else with this kind of check?

@Jade-GG Jade-GG changed the title [5.x] Don't run track on turbo previews & make it a "once" event [5.x] Fix track events being duplicated Apr 16, 2026
@royduin royduin merged commit de57acc into master Apr 30, 2026
16 of 18 checks passed
@royduin royduin deleted the Jade-GG-patch-4 branch April 30, 2026 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants