Track custom events

Legacy Tracker Documentation

For the legacy tracker doc, check our guide here.

Custom events are events you choose to track. They are custom in the sense that you can give them any name you want.

Use them in various situations — for example, in an eCommerce shop, to track cart events. The syntax is:

1Brevo.push([
2 "track",
3 event_name, /* mandatory */
4 properties, /* optional */
5 event_data /* optional */
6]);

Parameters:

AttributeDatatypeDescriptionValue
event_nameStringName of your event"cart_updated"
propertiesJSON objectDescribes the state of the visitor{"email": "john.doe@email.com","FIRSTNAME": "John","LASTNAME": "doe"}
event_dataJSON objectJSON object used to pass information about the eventSee example below

Example event_data:

1event_data = {
2 "id": "cart:1234",
3 "data": {
4 "total": 280,
5 "currency": "USD",
6 "url": "www.example.com",
7 "items": [{
8 "name": "Black shoes",
9 "price": 90,
10 "quantity": 2,
11 "url": "www.example.com/black-shoes",
12 "image": "www.example.com/black-shoes.jpg"
13 }
14 ]
15 }
16}

Example

1var event_name = "cart_updated";
2var properties = {
3 "email": "john.doe@email.com",
4 "FIRSTNAME": "John",
5 "LASTNAME": "doe"
6}
7
8var event_data = {
9 "id": "cart:1234",
10 "data": {
11 "total": 280,
12 "currency": "USD",
13 "url": "www.example.com",
14 "items": [{
15 "name": "Black shoes",
16 "price": 90,
17 "quantity": 2,
18 "url": "www.example.com/black-shoes",
19 "image": "www.example.com/black-shoes.jpg"
20 }
21 ]
22 }
23}
24
25Brevo.push([
26 "track",
27 event_name, /* mandatory */
28 properties, /* optional */
29 event_data /* optional */
30]);