ampproject / ampproject/amphtml
Story Player: Analytics events do not always fire when moving backwards
- Dominant language
- JavaScript
- Stars
- 14.9k
- Forks
- 4.1k
- PR merge metrics
- No merged PRs in 30d
Description
### 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](https://github.com/ampproject/amphtml/issues/37971) 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.
1. Add a GA4 tracking ID to WP Admin > Web Stories > Settings
2. Set the default advancement mode to Manual
3. Create four Stories
4. Add the Web Stories block to a post, choosing Latest Stories and Box Carousel. Or paste in ``
5. Save the post and view
6. Open the [GA4 Debugger extension](https://chromewebstore.google.com/detail/debugger-for-google-analy/nomnoimacbncclfbnfaingniikblfbji) to monitor events
7. Click on the first Story in the Carousel and observe the Page View and Custom Event appear in the debugger
8. Click on the arrow to skip to the second Story and observe the Page View and Custom Event appear in the debugger
9. Click on the arrow to skip to the third Story and observe the Page View and Custom Event appear in the debugger
10. Click on the arrow to skip to the fourth (and last) Story and observe the Page View and Custom Event appear in the debugger
11. Click on the arrow to go back to the third Story and observe that no GA events fire
12. Click on the arrow to go back to the second Story and observe the Page View and Custom Event appear in the debugger
13. 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
```shell
```
### Browser(s) Affected
Chrome
### OS(s) Affected
_No response_
### Device(s) Affected
_No response_
### AMP Version Affected
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.