The Analytics constructor accepts the following parameters:
Parameter
Type
Description
flushAt
Integer
The maximum number of events to store locally before forwarding to Hightouch. Defaults to 20.
flushInterval
Integer
The maximum amount of time (in milliseconds) to store events locally before forwarding to Hightouch. Defaults to 10000.
maxInternalQueueSize
Integer
The maximum number of events to store locally. This may be configured separately from flushAt because the event requests to Hightouch may fail, in which case they remain on the queue so that they can be retried.
logLevel
String
The log level for internal logs. Can be set to log, info, debug, warn, error, or none. Defaults to info.
Unlike the Browser SDK, it does not persist the user ID and
traits locally, so user IDs must be explicitly added to other events. This is
because server side events are usually servicing many different users at once.
The first argument to the method is an object representing the identify event to be sent. The second argument is an optional callback that's invoked after the event is sent.
client.identify(message, [callback])
The message object may include the following fields:
Parameter
Type
Description
userId
String
The user's persistent ID
anonymousId
String
The user's anonymous ID. This is automatically set if both userId and anonymousId are omitted.
traits
Object
Additional traits about the user, such as email and name.
context
Object
Overrides to values in the event context. By default, context contains information autocollected by the SDK.
timestamp
Date
The date of the message. When backfilling data, this can be set to the past. By default, this is autoset to the current date.
The first argument to the method is an object representing the track event to
be sent. The second argument is an optional callback that's invoked after the
event is sent.
client.track(message, [callback])
The message object may include the following fields:
Parameter
Type
Description
userId
String
The user's persistent ID
anonymousId
String
The user's anonymous ID. This is automatically set if both userId and anonymousId are omitted.
event
String
The name of the event.
properties
Object
Additional properties about the event, such as product_id.
context
Object
Overrides to values in the event context. By default, context contains information autocollected by the SDK.
timestamp
Date
The date of the message. When backfilling data, this can be set to a date in the past. By default, this is autoset to the current date.
The first argument to the method is an object representing the page event to
be sent. The second argument is an optional callback that's invoked after the
event is sent.
client.page(message, [callback])
The message object may include the following fields:
Parameter
Type
Description
userId
String
The user's persistent ID
anonymousId
String
The user's anonymous ID. This is automatically set if both userId and anonymousId are omitted.
category
String
The page's category. For example "Docs"
name
String
The page's name. For example "Getting started"
properties
Object
Additional properties about the event, such as url.
context
Object
Overrides to values in the event context. By default, context contains information autocollected by the SDK.
timestamp
Date
The date of the message. When backfilling data, this can be set to a date in the past. By default, this is autoset to the current date.
The first argument to the method is an object representing the screen event to
be sent. The second argument is an optional callback that's invoked after the
event is sent.
client.screen(message, [callback])
The message object may include the following fields:
Parameter
Type
Description
userId
String
The user's persistent ID
anonymousId
String
The user's anonymous ID. This is automatically set if both userId and anonymousId are omitted.
category
String
The screen's category. For example "Docs"
name
String
The screen's name. For example "Getting started"
properties
Object
Additional properties about the screen.
context
Object
Overrides to values in the event context. By default, context contains information autocollected by the SDK.
timestamp
Date
The date of the message. When backfilling data, this can be set to a date in the past. By default, this is autoset to the current date.
The first argument to the method is an object representing the group event to
be sent. The second argument is an optional callback that's invoked after the
event is sent.
client.group(message, [callback])
The message object may include the following fields:
Parameter
Type
Description
userId
String
The user's persistent ID
anonymousId
String
The user's anonymous ID. This is automatically set if both userId and anonymousId are omitted.
groupId
String
The id for the group.
traits
Object
Additional traits about the group, such as company_name.
context
Object
Overrides to values in the event context. By default, context contains information autocollected by the SDK.
timestamp
Date
The date of the message. When backfilling data, this can be set to a date in the past. By default, this is autoset to the current date.
Ready to get started?
Jump right in or a book a demo. Your first destination is always free.