Skip to Content

crmForm()

Easily collect form data for the CRM by adding a classes to input fields.

JavaScript February 7, 2021

Usage

JavaScript
.crm-column_name

Parameters

column_name
(Required) (String) The name of the column to add the input value to
Default: None

Parameter Notes

This function looks for form [class*="crm-"] which is any input field in a form with a class that begins with “crm-“. The string after the “crm-” in the class name will be used as the column name in the crm() send, the value of the input field will be used as the cell data.

Request or provide clarification »

Examples

JavaScript
<input class="crm-first_name" type="text" placeholder="Enter your first name..." />

Additional Notes

This function is automatically triggered on wpcf7:submit so all forms using Contact Form 7.

Source File

Located in /assets/js/modules/analytics.js on line 1348.

No Hooks

This function does not have any filters or actions available. Request one?
JavaScript
nebula.crmForm = async function(formID){
    let crmFormObj = {};

    if ( formID ){
        crmFormObj['form_contacted'] = 'CF7 (' + formID + ') Submit Attempt'; //This is triggered on submission attempt, so it may capture abandoned forms due to validation errors.
    }

    jQuery('form [class*="crm-"]').each(function(){
        if ( jQuery(this).val().trim().length ){
            if ( jQuery(this).attr('class').includes('crm-notable_poi') ){
                ga('set', nebula.analytics.dimensions.poi, jQuery('.notable-poi').val());
            }

            let cat = /crm-([a-z\_]+)/g.exec(jQuery(this).attr('class'));
            if ( cat ){
                let thisCat = cat[1];
                crmFormObj[thisCat] = jQuery(this).val();
            }
        }
    });

    if ( Object.keys(crmFormObj).length ){
        nebula.crm('identify', crmFormObj);
    }
};

Override

To override or disable this JavaScript function, simply redeclare it with the exact same function name.

JavaScript
nebula.crmForm = function(column_name){
    //Write your own code here, leave it blank, or return false.
}