Skip to content

Latest commit

 

History

History
39 lines (35 loc) · 1.32 KB

04_tracker.md

File metadata and controls

39 lines (35 loc) · 1.32 KB

Tracker Component

This component will enable the tracker functionality. If enabled, this extension tries to submit insensible data like dropdown selection, checked radios/boxes to google analytics or matomo.

Configuration:: You need to listen to the form_builder_submission event in your tag manager!

Enable Component

import {Tracker} from 'js-pimcore-formbuilder';
document.addEventListener('DOMContentLoaded', () => {
    document.querySelectorAll('.formbuilder.ajax-form').forEach((form) => {
        new Tracker(form);
    });
});

Extended Usage

document.addEventListener('DOMContentLoaded', () => {
    document.querySelectorAll('.formbuilder.ajax-form').forEach((form) => {
        new Tracker(form, {
            onBeforeSubmitDataToProvider: (data, formName, $form) => {
                // add some special value to data
                // warning: in some cases, no data will be submitted (gtag, ga)
                return data;
            },
            provider: 'google', // choose between "google" or "matomo"
            trackDropDownSelection: true,
            trackCheckboxSelection: true,
            trackRadioSelection: true,
            trackHiddenInputs: true,
            invalidFieldNames: ['_token', 'formCl', 'formRuntimeData', 'formRuntimeDataToken'],
        });
    });
});