Route data¶
Once the Web 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 targets
and namespaces
parameters.
Default routing¶
The Web SDK contains a config
command to configure routing. For example, you
can send data to a specified account using a script_token
and a scope
:
orb("config", "SCRIPT_TOKEN", { scope: "SCOPE" });
By default, track
events route to all targets, namespaces and script tokens. You can override
the routing that's specified by the Web SDK by adding the targets
parameter
to track commands. For example, the following view
event is sent only to
namespace 'n1' for script token 'abc123', regardless of what was configured previously:
orb("track", "view video", {
action: "view",
object: "video",
namespaces: "n1",
token: "abc123",
});
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 orbee is oa
. Otherwise, the default scope name will be discussed with involved parties.
Namespaces¶
You can organize where your events fire using namespaces.
INFO
The common namespace semantic will either be in the pattern of com.*
or just simply __orbee
.
Namespaces can be added to the configuration of a script token and a scope, and help route events to their proper destination:
// Configure namespaces with the differnt script tokens and same scope
orb("config", "SCRIPT_TOKEN_1", { namespace: "namespace1", scope: "oa" });
orb("config", "SCRIPT_TOKEN_2", { namespace: "namespace2", scope: "oa" });
// Routes to 'SCRIPT_TOKEN_1'
orb("track", "view video", {
action: "view",
object: "video",
namespaces: "namespace1",
token: "SCRIPT_TOKEN_1",
});
You can also route an event to multiple namespaces, like this:
// Configure namespaces with the same script token and scope
orb("config", "SCRIPT_TOKEN_1", { namespace: "n1", scope: "oa" });
orb("config", "SCRIPT_TOKEN_1", { namespace: "n2", scope: "oa" });
// Routes to namspaces 'n1' and 'n2'
orb("track", "view video", {
action: "view",
object: "video",
namespaces: ["n1", "n2"],
token: "SCRIPT_TOKEN_1",
});
WARNING
Namespaces are unique to a script token AND a scope. Please be wise with your naming and double-check that the namespace name is not already taken for the desired script token and scope.
Providing your namespace implementation¶
Using namespaces to organize and route events is an easy way to interact with the Web SDK from your own code. However, namespaces require another critical feature: their implementation!
The implementation will provide the Web SDK's full feature-set, as well as any additional plugins your implementation requires. This can be done in three ways:
- Use the default installation method. The script fetched with a script token will always install any namespaces configured through Orbee's Platform.
- Install via the
install
bootloader command. This only works if you know exactly where the namespace script is installed, or are rolling your own. - The bootloader will fetch it for you. (coming soon) When providing a script token with a namespace name, the namespace for that script token will be automatically fetched and installed.