Add this to before you load any 3p (especially GTM) in the document.
What it does is when it executes:
- for click, auxclick, mousedown, keyup and submit, installs a
document
leveladdEventListener
override that intercepts added listeners if it's likely they from from a 3p (-> based on the 3rd argument passed to the fn)
On the document load
event (so that it executes after GTM etc.):
- for the same events, installs a
document.body
level override - overrides
dataLayer.push
andgtag()
to yield first