--- title: "CustomForm" slug: "customform" updated: 2024-03-18T14:13:35Z published: 2024-03-18T14:13:35Z canonical: "docs.mapp.com/customform" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.mapp.com/llms.txt > Use this file to discover all available pages before exploring further. # CustomForm You can create a custom form and use it for tracking if you are using forms on your page that are not created by using the html tag "
". ## Class ### constructor Create an instance of the class "CustomForm" and pass form name and all belonging form fields which should be tracked. Pass the custom form to the Smart Pixel to track it. ```javascript /** * @param {string} name * @param {HTMLElement[]|CustomFormField[]} [elements] * * @constructor */ wtSmart.extension.form.CustomForm(name, elements); ``` ### add You can add all form fields you want to track. ```javascript /** * @param {HTMLElement|CustomFormField} element * * @returns {wtSmart.extension.form.CustomForm} */ customFormInstance.add(element) ``` ### setAttribute Set an attribute. ```javascript /** * @param {string} key * @param {string} value */ customFormInstance.setAttribute(key, value) ``` ### getAttribute Get an attribute value. ```javascript /** * @param {string} key * * @returns {string} */ customFormInstance.getAttribute(key); ``` ### submit Change the internal form status to "submitted". ```plaintext customFormInstance.submit(); ``` ### addEventListener ```javascript /** * @param {string} evt * @param {function} func */ customFormInstance.addEventListener(evt, func); ``` ### removeEventListener ```javascript /** * @param {string} evt */ customFormInstance.removeEventListener(evt); ``` ### Example ```xml
                           Mr.
   Ms.
   Mail me more info
   E-Mail me more info
           
``` ```javascript // create a custom form var customFormInstance = new wtSmart.extension.form.CustomForm(    'custom form name',    [        document.getElementById('001'),        document.getElementById('002'),        document.getElementById('003'),        document.getElementById('004'),        document.getElementById('005'),        document.getElementById('006')    ] ); // add new form fields customFormInstance    .add(document.getElementById('007'))    .add(document.getElementById('008'))    .add(document.getElementById('009'))    .add(document.getElementById('010'))    .add(document.getElementById('011'))    .add(document.getElementById('012'))    .add(document.getElementById('013')); // set an attribute customFormInstance.setAttribute('foo', 'bar'); // get an attribute var attribute = customFormInstance.getAttribute('foo'); // change the internal form status to 'submitted' customFormInstance.submit(); // add event listener customFormInstance.addEventListener('submit', function() {    console.log('custom form was submitted'); }); // remove all event listener customFormInstance.removeEventListener('submit'); ```