Google Tags dataLayer event code for contact form

Does anyone have the javascript to add the contact details into the dataLayer so it can be reported properly as an event by Google Tags?

Here is a wordpress form example:

document.addEventListener('wpforms.submit', function(event) {
    if ( === 'wpforms-18') { 
        var formData = new FormData(;
        window.dataLayer = window.dataLayer || [];
            'event': 'wpformsFormSubmit',
            'formData': {
                'name': formData.get('wpforms-18-field_0'),
                'phone': formData.get('wpforms-18-field_4'),
                'email': formData.get('wpforms-18-field_1')