Logging Goals and Events with JavaScript

Out of the box, Triggerbee records the traffic on the pages you added the script to. Triggerbee records pageviews, time on site, clicks on outbound links, referral source etc. Triggerbee also offers an option of automatically listening to the existing forms on your site, extracting field values such as email address and name. In this section, we will talk about the possibilities of sending extra data to Triggerbee using our simple to use javascript API.

Logging Events & Goals

Events and Goals are an important part of Triggerbee. You may have an ordering process that includes adding products to the cart, entering order details and finally making the purchase. Triggerbee lets you log events of every action.

Events that are particularly important and positive should be logged as a goal. Those visits get a medal in the list and can be used for filtering and initiate automation.

Event logging is done using three different methods. These methods send a call to Triggerbee tracking servers immediately.

Page views: mtr.log()

This is the default event, used for logging page views. The method accepts a URL and the TITLE of the page.

Goals: mtr.goal()

These logs goals in Triggerbee. A goal is an important event that can be used to trigger automation events. Achieved goals are added to the contact, and can also be added to the subscriber in the email software and CRM. The method accepts the name of the goal and the revenue.

Events: mtr.event()

These events should be used to log small interaction events, like clicking on an image, swiping, adding products to cart etc. The method accepts an optional argument declaring the event type also, such as "scroll" and "shopping cart". NOTE: Events does not support filtering or segmentations (for the time being). They are only useful for inspecting sessions in the visits feed.


mtr.log("/services", "Services");

Logging a simple event

Events appear below the URL of the previously logged pageview.

mtr.event( "Filled out form field");
mtr.event("Clicked on button");
mtr.event("50%", "scroll");

Logging a goal

mtr.goal("Posted a form"); 
mtr.goal("Checked out cart", 310); // 310 is the revenue

Note: To log goals and events on page load we recommend using the mtr.custom variable to configure the logging variables. To log goals and events on user interaction, such as clicking on buttons, scrolling, use the mtr.log(), mtr.event() and mtr.goal() methods. These methods are available after the tracking code is registered.  Read our scripting guidelines.

Still need help? Contact Us Contact Us