Skip to main content

Google Analytics 4 (GA4)

Web Source code Package

Google Analytics 4 (GA4) is a web analytics and marketing platform that helps businesses measure traffic across websites and apps. The destination automatically sends events to GA4 via gtag function. All you need to do is install the destination, and optionally map events to GA4's format. walkerOS takes care of loading the script and the function calls.

Installation

npm install @walkeros/web-destination-gtag

Setup

import { startFlow } from '@walkeros/collector';
import { destinationGtag } from '@walkeros/web-destination-gtag';

const { elb } = await startFlow();

elb('walker destination', destinationGtag, {
settings: {
ga4: {
measurementId: 'G-XXXXXXXXXX',
},
},
});

Configuration reference

PropertyTypeDescriptionMore
measurementId*stringGA4 Measurement ID from Google Analytics
debugbooleanEnable debug mode for GA4
includeInclude[]Array of properties to include in events
pageviewbooleanEnable automatic pageview tracking
server_container_urlstringServer-side GTM container URL
snakeCasebooleanConvert parameter names to snake_case
transport_urlstringCustom transport URL for GA4
* Required fields

Example

Settings
Result

Event Mapping

For custom event mapping (mapping.entity.action.settings.ga4):

PropertyTypeDescriptionMore
includeInclude[]Array of properties to include in this specific event

You are able to map your walkerOS events to match the respective requirements of each vendor. The mapping examples are using a live configuration.

Mapping examples

tip

The code examples are interactive. You can edit the code to generate your individual event mapping.

Find all of GA4's recommended events in this overview.

add_to_cart

Map your walkerOS event to get an add_to_cart gtag.js event.

Event
Mapping
Result

purchase

Map your walkerOS event to get a purchase gtag.js event.

Event
Mapping
Result
💡 Need Professional Support?
Need professional support with your walkerOS implementation? Check out our services.