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.

Consent events

If you want to log Consent from your own forms to Triggerbee, you need to use the javascript method  mtr_consent.logConsent();

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 contextTitle
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 consentText
"I consent to receive email communication and understand that my personal data will be handled in accordance with the privacy policy"

Logging consent on a form submission

The following command sends an event to Triggerbee indicating that the user ticked the Consent checkbox:  

window.mtr_consent.logConsent(contextTitle, consentText);	

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

This is how you would log Consent when a form is submitted on your website. The privacy policy version of the given Consent is set automatically to the privacy policy version currently published on the website.

// 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.

Still need help? Contact Us Contact Us