Hello @Rajvi_Chokshi!
Unfortunately eventListeners on the window is not support by Retool.
Our code runs the app in a sandbox and does not give user code access to the window for user tracking.
We currently have user tracking as a major feature for H2 of this year that our team is looking to add as this as been a common feature request.
I had suggested the custom components library as a temporary work around but it would only work for the HTML elements in the custom component (if at all, not confirmed).
Sorry for the inconvenience!