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
e.preventDefault()
doesn't have to be right at the beginning of the function call. Why not just have an if
statement to verify if everything is working correctly, and only call e.preventDefault()
if it does. If any function in the chain doesn't return the expected result, set a submitted
variable to false
, and don't prevent the default.
This might be a little more difficult to handle when it comes to anything asynchronous (such as your setTimeout
, but there will be ways to make fairly sure, depending on what your code looks like. So you can check if methods exist with if (_gaq.push)
(for example). You can't make 100% sure without testing every single combination in every browser, but I reckon you can get a pretty satisfactory result with this.