Created
September 12, 2022 21:56
-
-
Save peterjaffray/33b9b969070393f5af14e36c72fb8a8a to your computer and use it in GitHub Desktop.
# Track Elementor Form Submission Field Data in Tag Manager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function($) { | |
$(document).on('submit_success', function(evt) { | |
dataLayer = window.dataLayer || [] | |
var elements = evt.target.elements | |
var serialized = jQuery(elements).serializeArray() | |
console.log(serialized) | |
var obj = {} | |
serialized.forEach((i) => { | |
var key = i.name; | |
var value = i.value; | |
obj[key] = value | |
}) | |
window.dataLayer.push({ | |
'event': 'form_submission', | |
'data': obj | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment