tagRootLocation

Tags a TaggableElement to be tracked as RootLocationContext.

tagRootLocation = (parameters: {
id: string,
options?: TagLocationOptions,
onError?: TrackerErrorHandlerCallback
}) => TagLocationReturnValue
Low level api

Make sure to never use tagRootLocation while RootLocationContextFromURLPlugin is active. It will lead to multiple RootLocationContexts, which is forbidden.

For applications relying on URLs, RootLocationContext can be automatically instrumented via the RootLocationContextFromURLPlugin. This is enabled by default in BrowserTracker.

Reconfiguring or removing RootLocationContextFromURLPlugin
If you need RootLocationContextFromURLPlugin to track a different url slug, search parameter or the hashtag, you can reconfigure it to do so.

When reconfiguring the RootLocationContextFromURLPlugin is not a viable option, the Plugin should be removed before using this Location Tagger to instrument roots manually.

Parameters

typedefault value
requiredidstring
optionaloptionsTagLocationOptions
optionalonErrorTrackerErrorHandlerCallbackTrackerConsole.error

Returns

TagLocationReturnValue

Examples

import { tagRootLocation } from '@objectiv/tracker-browser';
<body {...tagRootLocation({ id: 'page' })}>
...
</body>
<Layout {...tagRootLocation({ id: 'page' })}>
...
</Layout>

Did you know ?

tagRootLocation is just syntactic sugar on top of tagLocation.