Modules: app/util/tracking/dataLayerUtils

Utilities to manage data layer tracking. You probably don't want to use these utilities directly. Instead, use the wrapper utilities provided in ./index.js that will also take care of other types of tracking

Source:

Members


<static, constant> dataLayerCustomEvent

Tracks a custom event. All custom events have been given the same name (see GTM_CUSTOM_EVENT const above) so we can define a trigger in the GTM admin console to respond to these events. For more information about the parameters passed to this util, see The Anatomy of Events

Source:

<static, constant> dataLayerPageView

Tracks a custom page view event to the data layer. The attributes of the event can be mapped in the GTM admin console. Currently, not all of them are being used.

Source:

<static, constant> dataLayerTimingEvent

Tracks a timing event in GTM. This is a custom event trigger, but it has been structured to match a timing event in Google Analytics so they can easily be mapped to GA in the GTM admin console. See https://developers.google.com/analytics/devguides/collection/analyticsjs/user-timings for more info.

Source:

<constant> DATA_LAYER_WINDOW_VAR :string

Variable name of the data layer on window

Type:
  • string
Source:

<constant> GTM_CUSTOM_EVENT :string

Event name for custom (non page-view) events

Type:
  • string
Source:

<constant> GTM_PAGE_VIEW :string

Event name for custom page view events

Type:
  • string
Source:

<constant> GTM_TIMING_EVENT :string

Event name for tracking timings

Type:
  • string
Source:

lastPushed :object

Stores lastPushed pageEvent variables

Type:
  • object
Source:

Methods


<static> dataLayerPush(items)

Pushes the given items to the dataLayer. Verifies that the dataLayer variable exists on window and skips the push on the NodeJS side.

Parameters:
Name Type Argument Description
items object <repeatable>

The items to push to the array. These arguments are the same as if you would call window.dataLayer.push( ... )

Source:
Returns:

True if the items were pushed (in the browser), false if it has been skipped (on the NodeJS side).

Type
boolean

dataLayerEvent(event [, attributes] [, state])

Push a new event to the data layer. This is a lower-level helper and should not be used directly. To track custom events, use the dataLayerCustomEvent() util.

Parameters:
Name Type Argument Default Description
event string

The name of the event to push

attributes object <optional>
{}

Attributes to add to the event

state object <optional>

The current redux state, used to get tracking meta properties

Source: