record
Contents
Learn how to use the record method to capture website events.
Description
The record method records custom website events.
Signature
ac('record', eventName, [customAttributes], [options])
Arguments
eventName
- Description: Name of the custom event
- Type: String
- Status: Required
- Restrictions: See Guidelines for custom event names.
customAttributes
- Description: Adds extra information to
pageview
event - Type: Object
- Status: Optional
- Restrictions: Flat object with properties of type string, number, Boolean, or customAttribute
Example
ac('record', 'product_added', { price: 15.99, code: 'CDE-123', name: 'Product', hasBatteries: false });
Additionally, define the datatype for the attribute to define the value better.
Example
ac('record', 'product_added', { price: {datatype: 'integer' value: 15, name: {datatype: 'string' value: 'Product'}}});
customAttributes for outcome value tracker
To derive the value of an outcome, create an event that comprises an associated value field. Then, using this event and the value field (within the same event), track the value of the outcome you created.
For example, the following event tracks the products added with the value, price. When you create an outcome using this event, the products added along with their value is tracked as part of the outcome.
- Description: Adds extra information to
pageview
event - Type: Object
- Status: Optional
- Restrictions: Flat object with properties of type string, number, or Boolean
Example
ac('record', 'product_added', { price: 15, code: 'CDE-123', name: 'Product', hasBatteries: false });
options
- Description: Used for more configuration
- Type: Object
- Status: Optional
- Properties: See the following table.
Name | Description | Type | Status | Default |
traitsMapper | Used to map custom attributes to traits. For more information, see Traits Mapper. | traitsMapper | ||
callback | Called once beacon is sent | function | optional | |
callbackTimeout | ms to wait for beacon to send | number | optional |