tagRootLocation
Tags a TaggableElement to be tracked as RootLocationContext.
tagRootLocation = (parameters: {
id: string,
options?: TagLocationOptions,
onError?: TrackerErrorHandlerCallback
}) => TagLocationReturnValue
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.
- Check out this guide for some examples.
Parameters
type | default value | ||
---|---|---|---|
required | id | string | |
optional | options | TagLocationOptions | |
optional | onError | TrackerErrorHandlerCallback | TrackerConsole.error |
Returns
Examples
- React
- Angular
import { tagRootLocation } from '@objectiv/tracker-browser';
<body {...tagRootLocation({ id: 'page' })}>
...
</body>
<Layout {...tagRootLocation({ id: 'page' })}>
...
</Layout>
Taggers only work by installing the Taggers Directive.
<main [tagRootLocation]="{ id: 'page' }">
...
</main>
tagRootLocation
is just syntactic sugar on top of tagLocation.