Route data¶
Once the JavaScript SDK has been installed, you can configure it to send data to
groups of accounts. This guide explains how to send data to specific accounts
and configurations using the scope
parameter.
Default routing¶
The JavaScript SDK contains a configure
command to configure routing. For
example, you can send data to a specified account using a api_token
:
oa.configure('api_token');
By default, this configure command also lives in a scope -- the default scope. Therefore, the below call is the same as the one above:
oa.getScope().configure('api_token');
If you want to configure your API token in your own scope, pass a scope
to the
getScope()
function, like this:
oa.getScope('scope').configure('api_token');
By default, all commands routed directly to oa
without a call to getScope()
are routed to the default scope. For example, if you want to track an event
inside your custom scope, you can do so like this:
oa.getScope('myScope').track('view video');
Scopes¶
Namespaces are organized and bundled into a scope. A scope is required during configuration and introduces another layer of specificty when firing events.
Info
The default scope for the JavaScript SDK is $default_scope
.