Scripting guidelines

To log goals and events  on page load, use the mtr.custom-variable to configure your logging variables.

var mtr_custom = mtr_custom || {};

To log goals and events  on user interaction such as when a user clicks a button (i.e. "Add to cart" or "Read this" or "Buy now") or when a user is scrolling, use one of these methods: 

mtr.log(url, pageTitle)
mtr.event(eventName)
mtr.goal(goalName)

These methods can only be used after the entire Triggerbee tracking script has loaded. 

Below is an example script that waits until the mtr-object containing the Triggerbee script is loaded. Insert it and call it on page load.

function waitForMtr() {
   if (typeof (window.mtr) !== "undefined") {
       //variable exists, do what you want
       // for example call mtr.goal("Purchase complete!", "995");
   }
   else {
       setTimeout(waitForMtr, 250);
   }
}
	

Namespaces

Sometimes you might want to customize the logging using the mtr_custom object in a namespace of your own. Then the Triggerbee script can't read those customizations. 

To avoid this use the following trick that makes sure that the mtr_custom object is accessible in the global space accessed the Triggerbee mtr-logger:

window.mtr_custom = mtr_custom;
	

Still need help? Contact Us Contact Us