Tracking eCommerce Events

This article outlines typical event logging for e-commerce stores.

General script suggestions:

Adding product to the shopping cart

Products added to shopping carts should be logged as a Goal using mtr.goal().

The fastest way to see when a visitor added a product to your shopping cart is to add an onclick()-event that triggers a Goal, directly on the “Add to Cart”-button (Within the <a href>-tag). See below:

Triggerbee Script: 

mtr.goal("Added product to cart");

Recommended usage:

<a href=”#add-to-cart” onclick="mtr.goal('Added product to cart');">Add to Cart<a/>

Logging Completed Purchase

A completed purchase in Triggerbee should be logged as a Goal using mtr.goal()

To log when a visitor has completed a purchase, the code below needs to be logged in the last step of the checkout process. The last step is preferably your “Thank You”-page/receipt page or the final button that completes the purchase.

mtr_custom.session = { 
name:"Erlich Bachman", 
email:"[email protected]"
mtr.goal("Purchase completed", 195); //195= order value in SEK/Euro/Dollar/etc

Examples for PHP:

mtr_custom.session = { 
email:"<?php echo $row['customer_email'];?>", 
name:"<?php echo $row['customer_name'];?>"
mtr.goal("Purchase completed", "<?php echo $row['order_price'];?>");

Here are a few examples of information that you can send to Triggerbee with this method:

  • Visitor email
  • Visitor Name
  • Purchase Value
  • Product Category
  • Product

You can also log what Products were purchased using the mtr.log() -method, where the string value "shoppingcart" is the event type (this string value CANNOT be changed). See below:

Triggerbee Script:

mtr.log(url, title, "shoppingcart");


mtr.log("/product-category/product-1/", "Product 1", "shoppingcart");
mtr.log("/product-category/product-2/", "Product 2", "shoppingcart");
mtr.log("/product-category/product-3/", "Product 3", "shoppingcart");

Example PHP:

mtr.log("<?php echo $row['product_url'];?>", "<?php echo $row['product_name'];?>", "shoppingcart");

Note: Replace the product_url and product_name examples from above with your own javascript variables.

Note: The mtr.log()-event will not send any information that can be used to filter or segment visitors inside Triggerbee.

If you need to send information that you can use to filter or segment visitors, you should use goals logging.

mtr.log() will send the logged information to Triggerbee where it can be found under the visitor’s activity list.

Member Login

A login event should be logged as a Goal in Triggerbee using mtr.goal().

Use case: Add a label that identifies a visitor as a “member”. When a visitor has a label attached to them, you can show widgets for anyone with that label, and send out more targeted email communication.

The easiest way to identify a visitor who logged in is to add an onclick()-event that triggers a Goal directly on the “Login”-button (Within the <a href>-tag). See below:

mtr_custom.session = { 
name:"Erlich Bachman", 
email:"[email protected]"
mtr.goal("Member login");

Sign up forms

When someone begins a signup application form you can log a goal for beginning signup and completing signup.

mtr.goal("Started member registration");

on signup completion (or your thank you page):

mtr_custom.session = { 
name:"Erlich Bachman", 
email:"[email protected]" 
mtr.goal("Completed member registration");

Still need help? Contact Us Contact Us