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)

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.

afterTriggerbeeReady(function () {
  // variable exists, do what you want
  // for example call mtr.goal("Purchase complete!", "995");

function afterTriggerbeeReady(callback) {
 var maxAttempts = 10;
 var counter = 0;

 function checkIsInitialized() {
   if (typeof ( !== "undefined") {
   } else {
     if (counter < maxAttempts) {
       setTimeout(function () {
       }, 250);


If you want to run some code before the Triggerbee script has finished loading, you can use the beforeTriggerbeeReady function, like this:
document.addEventListener('beforeTriggerbeeReady', function() { 
    // Do something before Triggerbee is initialized


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;

Goal Callback

If you want to wait for the callback of you goal, use this function.
mtr.goal('Callback goal', null, function() {
    //your code
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