Skip to main content

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.
optionalonErrorTrackerErrorHandlerCallbackconsole.error

Returns

TagLocationReturnValue

Events

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

LocationContextAutomatically triggers
ButtonContexttrackClick
SectionContexttrackSectionVisible, trackSectionHidden
ExpandableSectionContexttrackClick, trackSectionVisible, trackSectionHidden
InputContexttrackInputChange
LinkContexttrackClick
MediaPlayerContexttrackSectionVisible, trackSectionHidden
NavigationContexttrackSectionVisible, trackSectionHidden
OverlayContexttrackSectionVisible, trackSectionHidden

Usage example

import { tagLocation } from '@objectiv/tracker-browser';
<Layout {...tagLocation({ instance: makeSectionContext({ 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.