I spent almost my entire day yesterday steeped in JavaScript. UpBuild began doing work with the idea of form abandonment tracking about a year ago after I was inspired by a post by Simo Ahava. The idea is that you use JavaScript to listen to each input field of a form that’s interacted with, log that at each step along the way, and then if someone doesn’t hit the Submit button, send the complete history into Google Analytics.
It sounds pretty simple (or maybe it doesn’t sound simple at all), but it can get pretty complicated. We’ve been working on a client project in which we need to configure advanced form abandonment tracking (FAT) for not one but five (or is it six?) forms…some of which can appear on the same page and be interacted with one after the other without triggering an easy-to-hear “abandonment event”.
Anyhow, I think we have it close to finished now. I spun up a separate GTM container and tested new versions of all the tags we need. I just need to have Ruth and Will check it out and then import it into the client’s container.
Unfortunately, I had to do this thing I do where I essentially rewrite the entire code base rather than resolving the issues in my team’s code. It’s not because their code is bad; it’s because I don’t know what’s breaking it or otherwise causing it not to work and the only way I can solve the problem is by rewriting it from the ground up.

I was able to do some fun stuff this time, like putting reusable FAT functions (i.e., pushToDataLayer, prettifyFormInteractions) in a single, reusable GTM tag rather than duplicating that code in every form-specific tag. I felt pretty good about that. I also built a configuration array so that, ostensibly, someone could duplicate this tag and change the configuration settings all in one place and not have to touch any of the other code.
Yet, this whole process has made me realize that I’m not actually a JavaScript developer! Ha. Not that I ever thought that, but it’s funny that every time I begin to feel like, “I’m awesome at this stuff”, I shortly thereafter realize, “Wow. There’s soooo much I don’t know.”
Case in point: I just learned what variable hoisting is.
Discussions