Markus Baersch
Replacing gtag.js with walker.js
Why? How?
Demo: Running GA4 Using ssGTM
Why Not GTAG.JS?
(yes, same old song - but only a very brief summary. And a new color! Yay!)
gtag.js
some issues
(shortened version)
Source: likely to be blocked
Heavy: UA, GA4, GAds, Optimize,
partner badges + stuff
Not a “Stream To Rule Them All”:
no data without consent.
Consent Mode is not an option!
gtag.js
… is odd!
(also shortened version)
GA4 Session Handling & More:
● “first_visit” and “session_start”
● Conversions
● referral exclusion
● public measurement id
Options:
● ga4mp.dev by David Vallejo (->
ssGTM)
● Build your own format and send
to own endpoint Or use existing
tools like CDPs, Tealium (see
slides from MC Berlin 2022)
But:
● Blocking might still be a problem
● Costs?
● Control?
Alternatives exist!
perfect fit?
Feeding GA4 with walker.js
Open source: walker.js is a maintained
repo on GitHub
(Can) have all data you need: there
are timestamps, timings, hit
numbers…
https://github.com/elbwalker/walker.js
elbwalker
open source event tracker
Tagging Basics
uses a command / event queue
called “elbLayer” (per default)
scans DOM for data-elb attributes
and builds events and parameters
alternatively push events to
elbLayer manually via JavaScript
can send events to several
destinations
Destinations are consent sensitive
(walker.js can handle consent) https://github.com/elbwalker/sgtm-client-template/tree/main/example
events have an “open” structure to
contain default attributes, custom
attributes, session state, user
information, references… or whatever
Send example:
elb('page view',
{id: '/test/virtual/path1',
title: 'Virtual Page 1'},
'click',
{some_property: 14}
);
Events
Sending Stuff: walker.js Destinations
Every destination can handle events individually. We use it to send data to a ssGTM endpoint
GA4 Session Handling
GA4 wants session handling
(simple) example…
- is only active if consent is
present
- uses localStorage /
sessionStorage - which is
only possible on a single
domain AND host
- Can be part of destination
init block (see example code
for ssGTM tag)
elb("walker user",
{hash: sD.sessionId,
device: sD.clientId});
Tagging: GTM Tag Template
github.com/elbwalker/gtm-tag-template
Custom Templates for walker,js
Configuration
and walker,js Events to migrate
GTM setups
- destinations
- GA4 session data
- ecom item conversion
- use your existing variables
Endpoints
● use ssGTM and translate walker events to ssGTM event model
○ trigger / fire any tags as if gtag.js did generate all requests
● or build your own in Node, PHP or whatever and forward events to
GA4
○ cloud edge endpoints actually are an option ;)
● Remember: CNAME is not an option to avoid browser tracking
protection issues
ssGTM Example
use custom client for walker events
basic example and client template
available on Github:
github.com/elbwalker/
sgtm-client-template
-> fork and build what you need
(contribute if you like!)
send data to GA4 using
standard tag
enrich server-side
dimensions
add debug flag for
better debugging (kill
before publishing ;))
ssGTM Example
… or send data
(additionally or
exclusively) to Piwik
PRO, Matomo…
… or send directly to
BigQuery as
event-level raw data
ssGTM Example
Demo
sending events…
… from client-side GTM…
-> to ssGTM
-> to GA4
Medium article:
mbaersch.medium.com/
A-better-solution-for-ga4-
Data-capturing-replacing-
gtag-js-with-walker-js-
2b9fd291d919
No ssGTM? Use: worker for walker events
forward (few data) to GA4 using GAMP V2
think: add event to D1 cloud database ;)
Or build your endpoint as
- AWS Lambda
- GCP Cloud Function
- Azure Function
Cloud Functions & Workers
Can you see it?
Done!
Questions?
Game On!
download and play:
Walker | GTM Tags | Client | BQ:
github.com/elbwalker
Order:
markus-baersch.de/gtmbook

Replacing gtag.js with walker.js

  • 1.
    Markus Baersch Replacing gtag.jswith walker.js Why? How? Demo: Running GA4 Using ssGTM
  • 3.
    Why Not GTAG.JS? (yes,same old song - but only a very brief summary. And a new color! Yay!)
  • 4.
    gtag.js some issues (shortened version) Source:likely to be blocked Heavy: UA, GA4, GAds, Optimize, partner badges + stuff Not a “Stream To Rule Them All”: no data without consent. Consent Mode is not an option!
  • 5.
    gtag.js … is odd! (alsoshortened version) GA4 Session Handling & More: ● “first_visit” and “session_start” ● Conversions ● referral exclusion ● public measurement id
  • 6.
    Options: ● ga4mp.dev byDavid Vallejo (-> ssGTM) ● Build your own format and send to own endpoint Or use existing tools like CDPs, Tealium (see slides from MC Berlin 2022) But: ● Blocking might still be a problem ● Costs? ● Control? Alternatives exist! perfect fit?
  • 7.
  • 8.
    Open source: walker.jsis a maintained repo on GitHub (Can) have all data you need: there are timestamps, timings, hit numbers… https://github.com/elbwalker/walker.js elbwalker open source event tracker
  • 9.
    Tagging Basics uses acommand / event queue called “elbLayer” (per default) scans DOM for data-elb attributes and builds events and parameters alternatively push events to elbLayer manually via JavaScript can send events to several destinations Destinations are consent sensitive (walker.js can handle consent) https://github.com/elbwalker/sgtm-client-template/tree/main/example
  • 10.
    events have an“open” structure to contain default attributes, custom attributes, session state, user information, references… or whatever Send example: elb('page view', {id: '/test/virtual/path1', title: 'Virtual Page 1'}, 'click', {some_property: 14} ); Events
  • 11.
    Sending Stuff: walker.jsDestinations Every destination can handle events individually. We use it to send data to a ssGTM endpoint
  • 12.
    GA4 Session Handling GA4wants session handling (simple) example… - is only active if consent is present - uses localStorage / sessionStorage - which is only possible on a single domain AND host - Can be part of destination init block (see example code for ssGTM tag) elb("walker user", {hash: sD.sessionId, device: sD.clientId});
  • 13.
    Tagging: GTM TagTemplate github.com/elbwalker/gtm-tag-template Custom Templates for walker,js Configuration and walker,js Events to migrate GTM setups - destinations - GA4 session data - ecom item conversion - use your existing variables
  • 14.
    Endpoints ● use ssGTMand translate walker events to ssGTM event model ○ trigger / fire any tags as if gtag.js did generate all requests ● or build your own in Node, PHP or whatever and forward events to GA4 ○ cloud edge endpoints actually are an option ;) ● Remember: CNAME is not an option to avoid browser tracking protection issues
  • 15.
    ssGTM Example use customclient for walker events basic example and client template available on Github: github.com/elbwalker/ sgtm-client-template -> fork and build what you need (contribute if you like!)
  • 16.
    send data toGA4 using standard tag enrich server-side dimensions add debug flag for better debugging (kill before publishing ;)) ssGTM Example
  • 17.
    … or senddata (additionally or exclusively) to Piwik PRO, Matomo… … or send directly to BigQuery as event-level raw data ssGTM Example
  • 18.
    Demo sending events… … fromclient-side GTM… -> to ssGTM -> to GA4 Medium article: mbaersch.medium.com/ A-better-solution-for-ga4- Data-capturing-replacing- gtag-js-with-walker-js- 2b9fd291d919
  • 19.
    No ssGTM? Use:worker for walker events forward (few data) to GA4 using GAMP V2 think: add event to D1 cloud database ;) Or build your endpoint as - AWS Lambda - GCP Cloud Function - Azure Function Cloud Functions & Workers
  • 20.
  • 21.
  • 22.
    Game On! download andplay: Walker | GTM Tags | Client | BQ: github.com/elbwalker Order: markus-baersch.de/gtmbook