How dangerous is e.preventDefault();, and can it be replaced by keydown/mousedown tracking?

前端 未结 7 1823
隐瞒了意图╮
隐瞒了意图╮ 2021-02-04 17:51

I\'m working on a tracking script for a fairly sophisticated CRM for tracking form actions in Google Analytics. I\'m trying to balance the desire to track form actions accuratel

7条回答
  •  逝去的感伤
    2021-02-04 18:37

    I use a different approach, and generate the event tracking script in the page resulting from the submit. You could call it deferred event tracking.

    I wrote a blog post with all details about my approach to event tracking in backend actions. It is biased towards Java-Struts, but you can get the general idea.

    The rationale is that I want to track some things after they happened at the server side. In this kind of case, after the form was submitted and processed by the server.

    What I do (very summarized):

    • Store events in an object tied to the session (a list/queue)
    • Flush these events upon the next page render (generate the javascript and empty the queue)

提交回复
热议问题