Story Player: Analytics events do not always fire when moving backwards
Description
Bug Description
When navigating backwards between Stories in a Story Player, analytics events are not always firing. In a carousel with more than two Stories, navigating forwards between Stories triggers the events as expected. When you hit the back button to move to the previous Story though, the events do not fire, but only that one time. Subsequent clicks on the back navigation button do trigger events.
Expected Behaviour
When moving between Stories within a Story Player, GA events should always fire.
Additional Context
The only previous issue I found was this bug which sounds very similar but was identified and fixed years ago.
Reproduction Steps
This was using the Web Stories WP plugin in a fresh local development environment.
See video below for a demonstration of these steps.
- Add a GA4 tracking ID to WP Admin > Web Stories > Settings
- Set the default advancement mode to Manual
- Create four Stories
- Add the Web Stories block to a post, choosing Latest Stories and Box Carousel. Or paste in
<!-- wp:web-stories/embed {"blockType":"latest-stories","viewType":"carousel","fieldState":{"show_title":true,"show_author":false,"show_date":false,"show_image_alignment":false,"show_excerpt":false,"show_sharp_corners":false,"show_archive_link":true,"show_circle_size":false,"show_number_of_columns":false}} /--> - Save the post and view
- Open the GA4 Debugger extension to monitor events
- Click on the first Story in the Carousel and observe the Page View and Custom Event appear in the debugger
- Click on the arrow to skip to the second Story and observe the Page View and Custom Event appear in the debugger
- Click on the arrow to skip to the third Story and observe the Page View and Custom Event appear in the debugger
- Click on the arrow to skip to the fourth (and last) Story and observe the Page View and Custom Event appear in the debugger
- Click on the arrow to go back to the third Story and observe that no GA events fire
- Click on the arrow to go back to the second Story and observe the Page View and Custom Event appear in the debugger
- Click on the arrow to go back to the first Story and observe the Page View and Custom Event appear in the debugger
https://github.com/user-attachments/assets/6196114e-501b-446d-b5d4-05d07a9df972
Relevant Logs
Browser(s) Affected
Chrome
OS(s) Affected
No response
Device(s) Affected
No response
AMP Version Affected
No response