Log consent on your existing forms
Triggerbee logs and stores consent information on each contact when they convert through our Widgets. This article will take you through how to log it when a user submits an existing form on your website.
Note: If you haven't already, read this guide on how to add a checkbox and a policy link on your existing forms.
You can use the following events to send Consent information to Triggerbee:
|Consent information||Description||Js Variable||Example|
|Context Title||The title of the form or the page where the form was submitted||
|| Forms: "Checkout form" "Contact form" "Widget 20% off"
Page titles: "About us" "Acme Inc - A better way to do business" "Acme Inc - Contact us"
|Consent Text||The text that the user agrees with and consents to||
Logging consent on a form submission
The following command sends an event to Triggerbee indicating that the user ticked the Consent checkbox:
You can rename your variable for the Title or Text, but the order of appearance is important. The first parameter
consentTitle logs the Title of the form or page, and the second parameter
consentText logs the text that the user leaves their consent to.
Note: If you already use
mtr.goal() to log a goal when the form is submitted, it's not necessary to send the Consent information to Triggerbee separately.
To stop the Consent data to be sent to Triggerbee separately, you can add a
false parameter to the variable
var sendEventToTracker = false; window.mtr_consent.logConsent (contextTitle, consentText, sendEventToTracker);
Example: How to log consent when a form is submitted
// Get the page title and store it in a variable // Recommended way is to get the form name var contextTitle = window.document.title; // Find the consent checkbox label var consentTextIdentifier = 'label[for="consent"]'; // Store the label text in a variable var consentText = document.querySelector(consentTextIdentifier).innerText; // Do not send the consent data to the tracker separately // The mtr.goal() event makes sure the data gets sent var sendToTracker = false; // Add your consent data on the contact in Triggerbee window.mtr_consent.logConsent(contextTitle, consentText, sendToTracker);
Note: Before making this call you must first log the email address of the user, see instructions here.