tracking user engagement gets messy when sessions expire mid-interaction. instead of relying on default timeouts, u can push a
custom dimension to ur data layer whenever a specific
onbeforeunload
event triggers. this helps distinguish between a user actually leaving the site and a simple background refresh.
window.addEventListener('beforeunload', () => { gtag('set', 'dimension1', 'session_interrupted'); });applying this logic ensures ur
conversion paths remain accurate by flagging incomplete journeys. it prevents
inflated bounce rates from skewing your attribution models.
just make sure to clear the dimension on the next page load to avoid data leakage ⚡