Google Analytics 4 (GA4)
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
Property | Type | Description | More |
---|---|---|---|
measurementId* | string | GA4 Measurement ID from Google Analytics | |
debug | boolean | Enable debug mode for GA4 | |
include | Include[] | Array of properties to include in events | |
pageview | boolean | Enable automatic pageview tracking | |
server_container_url | string | Server-side GTM container URL | |
snakeCase | boolean | Convert parameter names to snake_case | |
transport_url | string | Custom transport URL for GA4 |
Example
Event Mapping
For custom event mapping (mapping.entity.action.settings.ga4
):
Property | Type | Description | More |
---|---|---|---|
include | Include[] | 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
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.
purchase
Map your walkerOS event to get a purchase gtag.js event.