Track Method

Overview

The track method is used to track any user behaviour as event. You may track any behaviour that you would like to use to segment users in CrossEngage to use for campaigns. These can be anything from page views, completing purchases, viewing the cart, adjusting delivery preferences to changing a products' colors in an onsite configurator.

The track method has the following structure:

ce('track', 'Added Product', { 'sku':'E12371'});

Method Parameters

Value

Type

Description

eventName

string

The name of the event your are sending to CrossEngage.

attributes

object

Object that contains information about the event, see examples below.

Implementation

Standard CrossEngage events

CrossEngage offers a range of predefined events which you can call without requiring any further event definition.

Viewed Product

A user views a specific product on your website:

var attributes = {     
    'sku': '46493-32',     
    'name': 'Uno Card Games',     
    'price': 300.00,     
    'currency': 'USD',     
    'category': 'Games' }; 

ce('track','Viewed Product', attributes);

Added Product / Removed product

A user adds a product or removes a product from their cart:

var attributes = {   
  'sku': '16493-37',     
  'name': 'Uno Card Games',    
  'price': 300.00,     
  'currency': 'USD',     
  'category': 'Games' ,    
  'cart': {        
    'products': [            
      {                
      'sku': '45790-32',                 
      'price': 200,                 
      'name': 'Monopoly 3rd Edition',                 
      'category': 'Games',                 
      'currency': 'USD'            
      },             
      {              
      'sku': '65112-30',                 
      'price': 149.99,                
       'name': 'Catan',                
      'category': 'Games',                 
      'currency': 'USD'            
      }        
    ]    
  }};
  
ce('track','Added Product', attributes);
ce('track','Removed Product', attributes);

For all product-related events containing the cart object, the full current state of the cart should be passed, as the information in CrossEngage will be overwritten with each such event. The cart object itself is not customisable, meaning no custom attributes (like cart.cartId) can be added. Custom attributes can be added on the event's root level.

In addition, thesku of the respective product should be provided on the top (root) level of the event data for all product-related events. This allows using this data with Product Feed events (Product Back/Low In Stock, Product Price Increased/Reduced) in real-time campaigns.

Searched Products

A user uses a search bar to look for products on your shop:

var attributes = {  
    'searchTerm': 'board games',  
    'productsDisplayed': 10
    };

ce('track','Searched Products', attributes);

Completed Order

A user completes a purchase.

For each product in the products array, CrossEngage will trigger an additional event namedOrdered Item. This event can be used to easily segment users that have purchased a particular item.

Note that sku is mandatory for each product in the products array.

var attributes = {  
    'orderId': '50314b8e9bcf000000000000',  
    'total': 47.68,  
    'shipping': 4.5,  
    'tax': 19,  
    'discount': 5,  
    'coupon': 'hasbros',  
    'currency': 'USD',  
    'cart': {    
        'total': 40.49,    
        'currency': 'EUR',    
        'products': [        
            {          
            'sku': '45790-32',          
            'name': 'Monopoly: 3rd Edition',          
            'price': 29.50,          
            'quantity': 1,          
            'category': 'Games'        
            },{          
            'sku': '46493-32',          
            'name': 'Uno Card Game',          
            'price': 10.99,          
            'quantity': 2,          
            'category': 'Games'        
            }]  
        }};

ce('track','Completed Order', attributes);

Sending Completed Order via Feed is recommended for historical event. Once your historical orders have been added to our system, Completed Order event is mostly done via API.

Viewed Cart

A user views their cart anywhere on your site. You can trigger this either on loading the full cart page or even a cart overlay that is triggered from the navigation bar.

var attributes = {  
    'cart': {    
        'total': 40,    
        'currency': 'EUR',    
        'products': [			
            {			  
            'sku': '12351920', 			  
            'name': 'Stiletto Shoes', 			 
            'price': 20, 			  
            'quantity': 2			
            }]  
        }};
ce('track','Viewed Cart', attributes);

Sending custom events

The CrossEngage web tracking library allows you to also send custom events through the track method. To send custom events, please contact your dedicated Customer Success manager so that they can define these events and their properties for use within the CrossEngage platform.

To make it easier for us to prepare the events for you, please send your Customer Success manager the structure of the event in the following format:

{
'Custom Event Name': 
    {        
    'property 1 name': string,        
    'property 2 name': boolean
    }
}

The formats supported by CrossEngage are the following:

  • string

  • integer

  • float

  • datetime

  • array

  • object

Use cases

A user makes a purchase

Using the Completed Order predefined CrossEngage event structure, call the track method with the entire cart object, including all products in the cart at the time of purchase.

When a Completed Order event is sent to CrossEngage, it will automatically trigger an Ordered Item event for each of the products in the cart to allow you to easily segment users ordering particular products of a specific category or a within a specific price range.

To segment all users that have completed orders, create a segment condition filtering Completed Order events. You may also use the event property cart.total with the operator greater than to additionally segment users that have completed an order over a given value.

A user views a cart overlay from the navbar of your site.

Using the Viewed Cart predefined CrossEngage event structure, call the track method with the entire cart object.

It is recommended that you send all products in the cart and all available product information to ensure that you gather all relevant data for segmentation purposes.

To segment all users that have viewed their cart, create a segment condition filtering Viewed Cart events. You may also use the event property cart.total with the operator greater than to additionally segment only users viewing carts over a given amount.

A user changes the color of a shoe in an onsite configurator.

Contact your dedicated Customer Success manager and define a custom event called, for example, Colour Changed with a structure as per below:

{    
'Colour Changed': 
    {        
    'colour': string,        
    'category': string,        
    'shoeSize': integer,        
    'imageUrl': string    
    }
}

Once receiving confirmation that the event is ready for use, you may now call the track method with a payload similar to the one below:

var attributes = {  
    'colour': 'red',  
    'category': 'shoes',  
    'shoeSize': 36,  
    'imageUrl': 'https://www.crossengage.io/images/catalog/product/stiletto.jpg'
    };
ce('track','Colour Changed', attributes);

To segment all users that have changed their shoe color in an online configurator, create a segment condition filtering Colour Changed events with the property category using the equals operator with the value shoes.

Consider sending all the information that is relevant as this may be used for message personalization.

Last updated