Skip to main content
Event()

Documentation on how to trigger a custom event

Michael Signorella avatar
Written by Michael Signorella
Updated over 6 months ago

Event

event is used to send events to ThoughtMetric.


thoughtmetric('event', [event name], [properties])
  1. (required) event name: name of the event

  2. (required) properties: javascript object of properties describing the order

Event Names

ThoughtMetric tracks three conversion events that you can optimize your marketing against. These events are outlined in the table below.

Event Name

Description

viewContent

A visit to a web page you care about. For example, a product or landing page.

addToCart

The addition of an item to a shopping cart or basket. For example, clicking an Add to Cart button on a website.

lead

A submission of information by a customer with the understanding that they may be contacted at a later date by your business. For example, submitting a form or signing up for a trial.

order

The completion of a purchase, usually signified by receiving order or purchase confirmation, or a transaction receipt.

Basic Order Event Example

The most basic event call for an order simply sends the required fields.

thoughtmetric('event', 'order', {
transaction_id: '123',
total_price: 55.00,
currency: 'USD',
orderCurrency: 'USD'
})


โ€‹

Detailed Order Event Example

The below example sends more detailed pricing information along with the order event. This includes subtotal, discounts, shipping, and tax amounts.

thoughtmetric('event', 'order', {
transaction_id: '123',
total_price: 55.00,
currency: 'USD',
orderCurrency: 'USD',
subtotal_price: 49.00,
total_tax: 1.00,
total_shipping: 5.00,
total_discounts: 0.00,
discount_codes: ["discount1"],
items: [{ product_name: "Shoes", quantity: 1, unit_price: 49.00}]
})

Add To Cart Event Example

This is an example of sending an addToCart event.

thoughtmetric('event', 'addToCart', {
total_price: 55.00,
currency: 'USD',
orderCurrency: 'USD'
})

Lead Event Example

This is an example of sending an addToCart event.

thoughtmetric('event', 'lead', {
lead_id: 'john.snow@winterfell.com'
})


โ€‹

List of supported properties

Field Name

Description

Type

Required (For order event)

transaction_id

Unique identifier identifying the transaction

string

Required

total_price

Total value of the order

number

Required

currency

The base currency that your store is configured to use

string

Required

orderCurrency

Currency that the order was placed in (USD, GBP)

string

Required

subtotal_price

The subtotal price of the order

number

Recommended

total_discounts

Total discount amount of the order

number

Recommended

total_shipping

Total shipping amount of the order

number

Recommended

total_tax

Total tax amount of the order

number

Recommended

item_quantity

Total number of items in the order

number

Recommended

items

Array of items sold

object

Recommended

discount_codes

Discount codes used on purchase

array

Recommended

lead_id

Identifier identifying the lead such as an email

string

Recommended

Did this answer your question?