/walkeros:walkeros-using-transformer-ga4from walkeros
Wires @walkeros/transformer-ga4 into a server flow to decode GA4 Measurement Protocol v2 hits into walkerOS events. Covers before-chain wiring, overriding default event mappings, dropping events, adding custom keys, and troubleshooting decoding issues.
Ships in walkeros. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
@walkeros/transformer-ga4@walkeros/transformer-ga4 decodes Google Analytics 4 Measurement Protocol v2
hits (/g/collect, /mp/collect) into walkerOS events. It sits in a server
source's before chain, reads the raw HTTP request via ctx.ingest, and
returns one walkerOS event per GA4 event in the hit (one hit can carry many
events).
Boundaries: server-side decoding in front of a server source, GA4 v2 only, G-
tids only by default. Per-field patching via extend/remove is supported.
transformer-ga4 into a server flow for the first timeuser_engagement)gtag('event', '<name>', ...) calltidPattern to accept Ads (AW-) or DC (DC-) trafficPick the source by runtime before copying the example below. gtag.js can
send several events in one POST body (one per line, as text/plain), so the
source must keep a non-JSON body as ingest.body. These server sources do:
@walkeros/server-source-express (shown below), the source runneros and the
walkeros/flow image serve. A text/plain body that is valid JSON is parsed;
any other text/plain body reaches the decoder as the raw string.
@walkeros/server-source-fetch: a (Request) => Response handler with no
port, for a runtime that calls it (Cloudflare Workers, Deno, Bun, Node.js
18+ with a fetch adapter), e.g. with collector from startFlow:
import { Source } from '@walkeros/core';
import type { SourceFetch } from '@walkeros/server-source-fetch';
export default {
fetch: Source.getSource<SourceFetch.Types>(collector, 'http').push,
};
runneros and the walkeros/flow image cannot serve it (they only mount a
source's Node httpHandler).
sourceCloudFunction from @walkeros/server-source-gcp on Google Cloud
Functions.
sourceLambda from @walkeros/server-source-aws on AWS Lambda. It answers a
POST without a body with 400, so body-less single-event hits are lost there.
The other sources take the same ingest and before config as the express
example. The fetch source also takes paths; none of them takes port.
{
"version": 4,
"flows": {
"default": {
"config": { "platform": "server" },
"sources": {
"http": {
"package": "@walkeros/server-source-express",
"config": {
"settings": {
"port": 8080,
"paths": ["/g/collect"]
},
"ingest": {
"map": {
"url": { "key": "url" },
"path": { "key": "path" },
"method": { "key": "method" },
"body": { "key": "body" }
}
}
},
"before": "ga4"
}
},
"transformers": {
"ga4": { "package": "@walkeros/transformer-ga4" }
},
"destinations": {
"log": { "package": "@walkeros/destination-demo" }
}
}
}
}
Wiring rules:
/collect by default and matches paths exactly.
gtag.js sends to /g/collect, so set settings.paths to ["/g/collect"] (or
the full path, if the collector URL carries a path prefix). Without it every
GA4 hit gets a 404.gtag('config', 'G-XXXXXXXXXX', { server_container_url: 'https://collect.example.com' }).
gtag.js appends /g/collect. With the walkerOS gtag destination, set
settings.ga4.server_container_url (or settings.ga4.transport_url). Hits
then go to the collector instead of Google. The /g/collect suffix, the
body-less single-event POST, and one-line-per-event batches are gtag.js
behaviour, not a walkerOS contract: confirm them in the browser Network tab.before: "ga4" runs every request on the source through the decoder, and a
request without GA4 parameters is dropped. If the source also receives
walkerOS events (for example on /collect), gate the chain:
"before": { "match": { "key": "ingest.path", "operator": "eq", "value": "/g/collect" }, "next": "ga4" }.server-source-express as the raw text/plain string, alongside GET
and body-less POST hits. A body sent as application/json must be valid JSON,
or express answers 400 before the decoder runs.transformer-ga4 belongs in source.before, not destination.before.
Decoding is a pre-collector concern: GA4 hits are not yet walkerOS events.ctx.ingest.url (required, string) and
ctx.ingest.body (optional, string). Raw text body only: pre-parsed JSON will
not decode. The express, fetch, GCP and AWS server sources keep a non-JSON
text/plain body (gtag's batched POST) as the raw string in ingest.body;
only a body that parses as JSON arrives parsed.Common mistake: config.ingest must be the map operator with direct field
paths on the request scope (no req. prefix), e.g.
{ "map": { "url": { "key": "url" } } }. The bare { "url": "req.url" } form
has no operator: walkeros validate and the bundle reject it
(MAPPING_VALUE_NO_OPERATOR). If it still runs, the collector logs an ERROR,
ctx.ingest stays empty, and the decoder fails every hit with missing-input.
This wiring contract (before-chain placement plus the config.ingest keys the
source must populate) is also surfaced as a package hint, so package_get on
@walkeros/transformer-ga4 returns it without this skill.
Use extend to add or override individual fields of a shipped default rule
without replacing it in full. Use remove to strip fields from the output.
The purchase default ships id, currency, value, tax, shipping, and
coupon. To add affiliation from a GA4 event parameter and drop currency:
"transformers": {
"ga4": {
"package": "@walkeros/transformer-ga4",
"config": {
"settings": {
"mapping": {
"purchase": {
"extend": {
"data": { "map": { "affiliation": "params.ep.affiliation" } }
},
"remove": ["currency"]
}
}
}
}
}
}
extend.data.map is deep-merged onto the default data.map, leaving id,
value, tax, shipping, and coupon intact. remove: ["currency"] strips
that field from the final payload. A null value in extend clears an
inherited field, for example "extend": { "data": { "map": { "tax": null } } }
drops tax from the default data.map.
Full replace: if you need to rewrite a rule from scratch (no merge), omit
extend and remove and supply the complete rule directly. A rule with neither
keyword keeps the existing replace behavior.
"settings": {
"mapping": {
"purchase": {
"name": "order complete",
"data": {
"map": {
"id": "params.ep.transaction_id",
"value": "params.epn.value",
"currency": "params.ep.currency",
"coupon": "params.ep.promo_code"
}
}
}
}
}
Set ignore: true on any key. This is how user_engagement, session_start,
and first_visit are silenced by default:
"settings": {
"mapping": {
"click": { "ignore": true }
}
}
For events fired via gtag('event', '<your_name>', ...):
"settings": {
"mapping": {
"newsletter_subscribe": {
"name": "newsletter signup",
"data": {
"map": { "source": "params.ep.source" }
}
}
}
}
Unknown event names fall through to the '*' key, which by default emits
ga4 track with data.event_name set to the original en. Override '*' to
change the global fallback rule.
tidPatternBy default only G- tids are accepted. Widen via a string regex (compiled at
init):
"settings": {
"tidPattern": "^(G|AW|DC)-"
}
settings.maxEvents (default 100) caps the events decoded from one request. A
POST body with more non-empty lines is dropped whole, before decoding:
"settings": {
"maxEvents": 250
}
The transformer returns walkerOS events with entity action names. Anything
downstream of the collector treats them as native events and needs no GA4
awareness:
"destinations": {
"bq": {
"package": "@walkeros/server-destination-gcp",
"import": "destinationBigQuery",
"config": {
"settings": {
"projectId": "my-eu-project",
"datasetId": "events",
"location": "EU"
}
}
}
}
Mappings reference fields on the decoded GA4Hit shape via dotted paths:
| Path | Meaning |
|---|---|
params.ep.X | Event parameter (string), e.g. params.ep.transaction_id |
params.epn.X | Event parameter (numeric), e.g. params.epn.value |
params.up.X | User property (string) |
params.upn.X | User property (numeric) |
items[0].X | First item in the items array |
items | Full items array (mapped to nested via item rules) |
Use params.ep.X not ep.X. The decoder materializes the prefixed keys under
the params namespace.
Set from the hit, each only when present, value as sent.
| Hit param | Event field |
|---|---|
dl | source.url (page URL) |
dr | source.referrer |
uid, cid, sid | user.id, user.device, user.session |
ul | user.language (browser language) |
sr | user.screenSize (screen resolution) |
p, _p, _s | source.platform, source.pageLoadId, source.hitSequence |
globals is left empty: globals.language is the site's language, not the
visitor's. Mappings or destinations that read globals.language or
globals.screen from decoded events must switch to user.language and
user.screenSize.timestamp is the receive time (Date.now()), not the session start (sid).
Event ids do not depend on it.source.url feeds server destinations that send a page URL (Meta, Snapchat,
Pinterest, Bing, TikTok, Criteo, Piwik PRO; Piwik PRO fails events without it
with missing-input) and the fingerprint transformer's default site input.
Fingerprint hashes of GA4-decoded events therefore change once on upgrade./g/collect means the source does not listen there. Set
settings.paths to include /g/collect (the express and fetch sources
default to /collect).source.config.ingest is the map operator and populates url
(required, string) and body (optional, string), e.g.
{ "map": { "url": { "key": "url" }, "body": { "key": "body" } } }. A bare
{ "url": "req.url" } object fails walkeros validate
(MAPPING_VALUE_NO_OPERATOR); at runtime ctx.ingest stays empty and every
hit fails with missing-input, one ERROR line per cause and minute.before: "ga4" is set on the source, not on a destination.tidPattern: by default ^G- blocks AW- / DC- traffic
silently.settings.maxEvents (default
100) is dropped whole. The client still gets a success response; the only
trace is one ERROR line with the line count and the cap. Raise the cap if
your own server-to-server batches are larger.params.ep.X, not ep.X.params object.extend), your data.map is the entire
rule. Use extend to inherit the defaults and add only the fields you need.@walkeros/server-source-express only rejects a POST body that is sent as
application/json and does not parse. gtag.js sends text/plain, which express
keeps as the raw string. If a proxy in front of the collector rewrites the
content type to application/json, restore text/plain.
gcs consent not appliedv1 decodes basic gcs (G1XX → marketing / analytics booleans) only.
Functional/preferences flags and the newer gcd parameter are not decoded.
Override the consent path manually if you need richer mapping.
G- tids only by default. Override tidPattern for Ads/DC.gcs only. No gcd, no functional/preferences flags.text/plain, one URL-encoded hit per line) reach ingest.body
raw on the express source.maxEvents events per request. Default 100; a larger batch is
dropped whole before decoding, because each event becomes its own push and a
source's batch limit does not cover a raw text body.data/map path syntax used in the GA4 mapping recipesSee the website docs for the authoritative reference and the README for the in-repo summary.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub elbwalker/walkeros --plugin walkeros22 skills in this plugin
/walkeros-create-cmp-sourceUse when creating a new walkerOS CMP (consent management platform) source. Structured fill-in-the-blanks workflow that turns any CMP's consent API into a walkerOS source package. Covers CookieFirst, Usercentrics, CookiePro/OneTrust patterns and generalizes to any CMP./walkeros-create-destinationUse when creating a new walkerOS destination to send events to a vendor or API (GA4/gtag, Meta/Facebook Pixel, Mixpanel, Amplitude, a custom HTTP API, Measurement Protocol), web or server-side. Example-driven workflow: research the vendor SDK and define step examples before implementing the destination interface, env pattern, and mappings./walkeros-create-sourceUse when creating a new walkerOS source to capture events (browser source, dataLayer interception, server/HTTP source, webhook receiver, event capture), web or server-side. Example-driven workflow: research the input format and define step examples before implementing the push interface, createTrigger, and env pattern./walkeros-create-transformerUse when creating a new walkerOS transformer to modify events in the pipeline (validate, enrich, or redact) at a before/next chain position. Example-driven workflow for the transformer interface, return values, and chaining./walkeros-debuggingUse when walkerOS events aren't reaching destinations, debugging event flow, or troubleshooting mapping issues. Covers common problems and debugging strategies./walkeros-mapping-configurationUse when configuring walkerOS event mappings for specific use cases. Provides recipes for GA4, Meta, custom APIs, and common transformation patterns.Other plugins' skills for the same job