GAController

GAController

new GAController(gaCode, optionsopt, gaCodes) → {GAController}

Source:

Class required to manage google analytics 4

Parameters:
Name Type Attributes Default Description
gaCode string

Google Analytic 4 Measurement ID

options string <optional>
{}

Custom analytic config options

gaCodes Array

Additional Measurement IDs

Returns:

GAController instance

Type
GAController

Methods

event(name, props) → {*}

Source:

Build event and send to gtag

Example
event({
  name: 'Button Click',
  time: new Date(),
  user: 'anon',
})
Parameters:
Name Type Description
name string

What the event should be called

props object

Key/values pairs of properties of the event

Returns:

Response from the global gtag method

Type
*

ga(args) → {*}

Source:

Direct access to ga

Parameters:
Name Type Description
args Object

Arguments for the global ga method

Returns:

Response from the global ga method

Type
*

gtag(args) → {*}

Source:

Direct access to gtag

Parameters:
Name Type Description
args Object

Arguments for the global gtag method

Returns:

Response from the global gtag method

Type
*

pageView(event) → {*}

Source:

Shortcut helper so send a page view event

Parameters:
Name Type Description
event PageViewEvent
Returns:

Response from the global gtag method

Type
*

uaEvent(event) → {*}

Source:

Build a predefined event and send to gtag

Parameters:
Name Type Description
event UAEvent
Returns:

Response from the global gtag method

Type
*