# Analytics & Conversion Tracking

The Hytiva Embed Code provides an event listener for tracking activity and conversion reliably, and with respect for customer privacy.

# Adding the Event Listener

To begin listening for events, simply modify the configuration object in your Hytiva Embed code to add the event listener.

Use the highlighted lines in following examples to start your solution:

TIP

Don't forget to add the comma , after the previous item in the config structure. 👍

Now, you can modify the functionality of the onAnalyticsEvent function to do what you like with each event, or use an example as it is.

# Events

When the event listener is added, you will receive the following events:

# User Login

user.login

Provides an identifier for the customer logged in. You can use this event to track unique customers, return customers, etc.

{
	"type": "user.login",
	"data": {
		"userId": "FzZ70uhk-UiMH3rYY81b9ZBUGxb8VpcNh6v45btV5n4"
	}
}
1
2
3
4
5
6

menu.item.detail

Lets you know when the customer views the details of a menu item, providing information about the product and its variant(s). For example, when a flower item, with multiple weight options is viewed, you will see multiple items returned, each with different option values.

# Cart Activity

cart.item.add cart.item.remove

Lets you know when an item is added to or removed from the cart, providing information about the product, variant, price, and quantity.

# Begin Checkout

cart.checkout.start

Lets you know when the customer begins the checkout process.

{
	"type": "cart.checkout.start",
	"data": {
		"type": "pickup",
		"items": [
			{
				"id": "566721.740259",
				"quantity": 1,
				"title": "Ghost Train Haze Shaker",
				"sku": "4493634",
				"brand": "Nature's Chemistry",
				"category": "sativa",
				"unitPrice": 70,
				"price": 70,
				"options": {
					"weight": "Quarter"
				}
			},
			{
				"id": "493366.658224",
				"quantity": 2,
				"title": "Marionberry Gummies",
				"sku": "3119996",
				"brand": "Wyld",
				"category": "edibles",
				"unitPrice": 20,
				"price": 20,
				"options": null
			}
		],
		"subtotal": 110,
		"total": 130.2125
	}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

# Order Completion

order.complete

Lets you know when the customer completes an order, providing details about the order, including its type, and the items on the order.

{
	"type": "order.complete",
	"data": {
		"type": "delivery",
		"items": [
			{
				"id": "566721.740259",
				"quantity": 1,
				"title": "Ghost Train Haze Shaker",
				"sku": "4493634",
				"brand": "Nature's Chemistry",
				"category": "sativa",
				"unitPrice": 70,
				"price": 70,
				"options": {
					"weight": "Quarter"
				}
			},
			{
				"id": "493366.658224",
				"quantity": 2,
				"title": "Marionberry Gummies",
				"sku": "3119996",
				"brand": "Wyld",
				"category": "edibles",
				"unitPrice": 20,
				"price": 20,
				"options": null
			}
		],
		"subtotal": 110,
		"total": 130.2125,
		"orderId": "a183f21"
	}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35