Collector Commands
The collector provides a core event processing engine that manages destinations,
consent, user data, and custom properties. Commands are executed through the
elb function
For browser-specific commands like DOM initialization and elbLayer communication, see Browser Source Commands.
destination
Add destinations to the collector for event processing. Destinations handle the actual delivery of events to third-party services.
Destinations are typically configured during collector initialization:
See destination-specific documentation for configuration options.
consent
Manage consent states for the collector. Names can be defined arbitrarily, but
common groups are functional, analytics, and marketing. Values are booleans, and
once a value is set to true it's treated as consent being granted.
Setting a consent state to false will immediately stop a destination from
processing any events. Previously pushed events during the run are shared with
existing destinations once consent is granted.
Learn more about consent management in detail.
on
Add event listeners to the collector. They get called when specific events occur
like run or consent changes.
Options depend on type and can also be an array for multiple listeners at
once.
run
With each run, the on-event will be called with instance as a parameter.
Every time the run command is called, the function will be executed:
consent
Every time the consent changes, the rules-matching function(s) will be called
with the parameters instance and consent.
The onConsent function will only be called when the marketing consent
changes:
user
Set user identification data for the collector. There are three levels: user (company's internal ID), device (longer-term identifier), and session (temporary identification).
User IDs are added to each event.
Use fully anonymized & arbitrary IDs by default and check your options with persistent user IDs with your data protection officer.
Learn more about identification and user stitching
custom
Set custom properties that are added to each event processed by the collector.
globals
Set global properties that are added to each event processed by the collector.
hook
Hooks customize the default behavior of the collector. Available hooks include
Push, DestinationInit, and DestinationPush. Hooks allow for validation,
manipulation, or cancellation of default behavior.
Add hooks to the collector to customize or enhance default processing.
Moments
The overall function execution order is as follows:
- prePush
- preDestinationInit
- postDestinationInit
- preDestinationPush or preDestinationPushBatch
- postDestinationPush or postDestinationPushBatch
- postPush
Others are:
- preSessionStart
- postSessionStart
Function signatures
In general, params will be prefixed as a parameter, containing fn which is
the original function and result for the post-hooks. Use the following
function signatures:
Adding a hook
Add hooks during collector initialization or via the hook command: