JavaScript API
identify()
Attach customer details to a visitor from the pixel.
Use identify to identify the customer who placed an order. Call it after a customer has completed an order.
thoughtmetric('identify', [customerID], [properties])
Parameters
| Parameter | Description | Required |
|---|---|---|
customerID | Unique identifier for this user | Required |
properties | JavaScript object of properties describing the customer | Required |
Supported properties
| Field name | Description | Type | Required |
|---|---|---|---|
email | Customer email | string | Required |
created_at | Date the customer was created | string | Recommended |
orders_count | Total number of orders this customer has placed | number | Recommended |
total_spent | Total amount spent by this customer | number | Recommended |
first_name | Customer first name | string | Optional |
last_name | Customer last name | string | Optional |
company | Customer company | string | Optional |
address1 | Customer address line 1 | string | Optional |
address2 | Customer address line 2 | string | Optional |
city | Customer city | string | Optional |
state | Customer state | string | Optional |
country | Customer country | string | Optional |
zip | Customer zip | string | Optional |
phone | Customer phone number | string | Optional |
Examples
Basic call
The most basic identify call sends only the required fields.
thoughtmetric('identify', 'john@snow.com', {
email: 'john@snow.com'
})
Detailed customer
This example sends more detailed customer spend information along with the identify call, including total_spent and orders_count.
thoughtmetric('identify', '0001', {
email: 'john@snow.com',
created_at: '2022-09-06 20:12:44 -0400',
total_spent: 55.00,
orders_count: 3,
first_name: 'Aegon',
last_name: 'Targaryen'
})