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

typedefault value
requiredinstanceLocationContext
optionaloptionsTagLocationOptionsDynamically calculated based on instance. See the Events table below.
optionalonErrorTrackerErrorHandlerCallbackTrackerConsole.error

Returns

TagLocationReturnValue

Events

Unless customized via the options parameter, the given instance determines which Events are triggered automatically:

LocationContextAutomatically triggers
ContentContext
ExpandableContexttrackPressEvent
InputContexttrackInputChangeEvent
LinkContexttrackPressEvent
MediaPlayerContext
NavigationContext
OverlayContexttrackVisibleEvent, trackHiddenEvent
PressableContexttrackPressEvent

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.