tagLocation
Tags a TaggableElement to be tracked as any LocationContext.
tagLocation = (parameters: {
instance: LocationContext,
options?: TagLocationOptions,
onError?: TrackerErrorHandlerCallback
}) => TagLocationReturnValue
caution
tagLocation
is a lower-level API. Unless really needed, it's easier to use specific Location Taggers APIs.
Parameters
type | default value | ||
---|---|---|---|
required | instance | LocationContext | |
optional | options | TagLocationOptions | Dynamically calculated based on instance . See the Events table below. |
optional | onError | TrackerErrorHandlerCallback | TrackerConsole.error |
Returns
Events
Unless customized via the options
parameter, the given instance
determines which Events are triggered automatically:
Usage example
import { tagLocation } from '@objectiv/tracker-browser';
<Layout {...tagLocation({ instance: makeContentContext({ id: 'layout' }) })}>
<div {...tagLocation({ instance: makeOverlayContext({ id: 'modal' }) })}>
...
</div>
</Layout>
Did you notice ?
In the example above we factored the instance
parameters by using Location Context Core Factories.
See also