RootLocationContextFromURL

All Events must contain a RootLocationContext in their Location Stacks.

On Web we retrieve this information from the first slug of URL by using the Location.href. This behavior is customizable.

Parameters

idFactoryFunction?: () => string;

The idFactoryFunction parameter can be used to customize how RootLocationContext identifier is generated.

Here is a simple example on how to reconfigure the Plugin:

import { RootLocationContextFromURLPlugin } from '@objectiv/plugin-root-location-context-from-url';
import { makeTracker } from "@objectiv/tracker-browser";

makeTracker({
applicationId: 'app-id',
endpoint: 'https://collector.app.dev',
plugins: [
new RootLocationContextFromURLPlugin({
idFactoryFunction: customIdFactoryFunction
})
]
});
tip

Check out this detailed how-to guide on how to configure Root Locations.

Installation

The package @objectiv/plugin-root-location-context-from-url is included by default in BrowserTracker.

Implementation

Implements PluginInterface's enrich.

enrich

Creates a new instance of RootLocationContext, where its identifier equals the result of idFactoryFunction, and adds it to the Location Stack of the outgoing Event in the first position.

validate

Nothing. RootLocationContext validation is performed by OpenTaxonomyValidationPlugin.

isUsable

True if both Document and Location interfaces are available.

Configuration

Can be disabled by setting BrowserTracker's trackRootLocationContextFromURL parameter to false.

caution

Disabling this plugin implies providing your own implementation, as RootLocationContext is still required.