Skip to content

feat: Migrate Analytics From Universal Analytics to GA4 - #33

Merged
Xtrimmer merged 1 commit into
masterfrom
xtrimmer/ga4-migration
Aug 9, 2026
Merged

Xtrimmer merged 1 commit into
masterfrom
xtrimmer/ga4-migration

Conversation

@Xtrimmer

@Xtrimmer Xtrimmer commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Problem

index.html loaded UA-120608786-1, a Universal Analytics property. Google stopped processing UA data on 1 July 2023 and deleted standard UA properties from 1 July 2024. The tag still loads and still returns a container, so nothing looks broken, but no hit has reached a report in three years. The site has had no working analytics for that entire period.

A straight swap to GA4 would also introduce a leak. GA4 sets page_location from document.location.href, and render.js accepts an ?invoice= parameter. Every shared link would send the full BOLT 11 invoice or BOLT 12 string — payment hashes, node pubkeys, amounts, and for lnp payer proofs the payer identity — to Google.

Solution

Point the tag at GA4 property G-KF4ZEM295Z and override page_location to origin + pathname.

Add decode_success and decode_error events, so reports show which formats people decode rather than page views alone. request_kind is model.kind on success and the leading prefix on failure, narrowed to the eight prefixes the page decodes; anything else reports unknown. error_stage sorts the 82 distinct error messages into input, format, structure, signature and validation. Both parameters draw on fixed vocabularies, so no part of the request string is transmitted — which also keeps the custom dimensions under GA4's cardinality limits.

updatePage runs on every keystroke, so events fire 1.5s after input settles. Verified in a fake-DOM harness: 60 keystrokes produce one event, an empty box produces none, and the page still renders when an ad blocker removes gtag.

Both parameters need registering as event-scoped custom dimensions in the GA4 UI before they appear in reports.

The page carried UA-120608786-1. Google stopped processing Universal
Analytics data on 1 July 2023 and deleted standard UA properties from
1 July 2024, so the tag has loaded without recording anything since.

Point the tag at the GA4 property G-KF4ZEM295Z and override
page_location to origin + pathname. GA4 otherwise reports the full
href, and the ?invoice= parameter this page accepts would put the
user's invoice, offer or payer proof into Google's reports.

Add decode_success and decode_error events so the reports show what the
tool is actually used for rather than page views alone. request_kind is
the decoded model kind on success and the leading prefix on failure,
narrowed to the eight prefixes the page decodes; error_stage sorts the
82 distinct error messages into five buckets. Both parameters draw on
fixed vocabularies, so no part of the request string is transmitted.

Events fire 1.5s after input settles, since updatePage runs on every
keystroke.
@Xtrimmer
Xtrimmer merged commit b1f08e7 into master Aug 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant