Setting identity of a visitor

A fundamental part of Triggerbee is the Identity Layer. By identifying visitors you are able to create 1-to-1 communication and create very specific segments for steering Onsite Campaign.

This article will take you through how to set identity of a visitor using javascript, as well ass passing other identity type data, such as name and telephone number.

Triggerbee contact fields and variables 

Contact information Default Js Variable
Email Yes
Name Yes
Organization Yes mtr_custom.session.organization
Telephone Yes mtr_custom.session.telephone
Title Yes mtr_custom.session.title
Username Yes mtr_custom.session.username
Shoe size No mtr_custom.session. shoesize
Gender No mtr_custom.session. gender
Website No mtr_custom.session. website
Country No mtr_custom.session. country
Any custom variable No mtr_custom.session. my-own-variable

How to identify a visitor from a form submission

Here's a full example of how to identify a visitor from a form submission such as a login form or contact form. 

This javascript needs to be run when the form is submitted.

// Start by finding the form class or ID<br>// Declare variables for each field you want to send to Triggerbee
// Declare a goal name to be set when the form is submitted
var form = document.querySelector('.myform');
var emailIdentifier = 'input[type="email"]';
var firstNameIdentifier = 'input[name="your-firstname"]';
var goalName = 'Form submission';

// Add an event listener and listen for the submit event
form.addEventListener('submit', function () {

 // Start by storing any existing customer variables or create a new object locally
 var tbContact = window.mtr_custom || {};

 // Get existing session/visit data or create a new object
 tbContact.session = tbContact.session || {};

 // Find the input for email, and set it as a contact variable
 var email = document.querySelector(emailIdentifier).value; = email;

 // Find the input for first name and set it as a contact variable
 var name = document.querySelector(firstNameIdentifier).value; = name;

 // Make sure Triggerbee's tracker picks up the contact data
 window.mtr_custom = tbContact;

 // The last step is to send the contact data to Triggerbee and identify the visitor by setting a goal


Tip: If you don't want to add a goal you can use mtr.log ("Form submission"); instead. 

Extending the Contact object with Custom Fields

You can extend the Contact object with custom fields. Read more here.

Did this answer your question? Thanks for the feedback! Please reach out to [email protected] if there's anything you'd like to add. There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us