Analytics snippets
How to Track Virtual Page Views in GA4 During an A/B Test
★★★ Technical level 3 of 3
Written by Neil Webley · Last updated
Send a meaningful virtual page visit when a test changes the apparent page.
What you need to know
Use Fire GA Page for a navigation-like state in a single-page application, not every small interaction. Replace test_X_page_Y with a stable documented name.
How to use it safely
Validate one event per intended transition in GA4 DebugView or Realtime and respect analytics consent.
Before publishing
- Use Staging to test control and every variant.
- Check matching and non-matching locations.
- Verify mobile, desktop, accessibility and analytics behaviour.
- Ask someone else to review the setup.