feat: smart visitor detection for GA/GTM #8

Merged
jmiller merged 1 commits from feat/smart-visitor-detection into main 2026-05-05 20:27:30 +00:00
Owner

Summary

  • Adds Smart Visitor Detection — pushes anonymised visitor properties to the dataLayer before GTM/GA4 loads
  • Properties: visitor_type (guest/logged_in), visitor_group (Joomla user group name), page_type (component.view)
  • Sets GA4 user_properties for persistent session-scoped dimensions
  • New admin toggle in Google tab (default: enabled, only visible when GTM or GA4 is active)
  • No PII (usernames, emails, user IDs) is ever sent

Files changed

  • src/index.php — PHP user detection + dataLayer push + GA4 user_properties
  • src/templateDetails.xml — New googlevisitordetection field
  • src/language/en-US/tpl_mokoonyx.ini — Label and description strings
  • src/language/en-GB/tpl_mokoonyx.ini — Label and description strings
  • CHANGELOG.md — Unreleased entry
  • README.md — Updated feature bullet
  • docs/ROADMAP.md — New Smart Visitor Detection section + param reference

Test plan

  • Enable GTM or GA4 in template settings, verify Smart Visitor Detection toggle appears and is ON by default
  • As a guest, inspect window.dataLayer in browser console — confirm moko.visitor_detect event with visitor_type: "guest", visitor_group: "none"
  • Log in as a registered user, verify visitor_type: "logged_in" and visitor_group shows the correct group name
  • With standalone GA4 (no GTM), verify gtag('set', 'user_properties', ...) is present in page source
  • Disable the toggle, confirm no visitor detection script is rendered
  • Disable both GTM and GA4, confirm the toggle is hidden in admin

🤖 Generated with Claude Code

## Summary - Adds **Smart Visitor Detection** — pushes anonymised visitor properties to the `dataLayer` before GTM/GA4 loads - Properties: `visitor_type` (guest/logged_in), `visitor_group` (Joomla user group name), `page_type` (component.view) - Sets GA4 `user_properties` for persistent session-scoped dimensions - New admin toggle in Google tab (default: enabled, only visible when GTM or GA4 is active) - No PII (usernames, emails, user IDs) is ever sent ## Files changed - `src/index.php` — PHP user detection + dataLayer push + GA4 user_properties - `src/templateDetails.xml` — New `googlevisitordetection` field - `src/language/en-US/tpl_mokoonyx.ini` — Label and description strings - `src/language/en-GB/tpl_mokoonyx.ini` — Label and description strings - `CHANGELOG.md` — Unreleased entry - `README.md` — Updated feature bullet - `docs/ROADMAP.md` — New Smart Visitor Detection section + param reference ## Test plan - [ ] Enable GTM or GA4 in template settings, verify Smart Visitor Detection toggle appears and is ON by default - [ ] As a guest, inspect `window.dataLayer` in browser console — confirm `moko.visitor_detect` event with `visitor_type: "guest"`, `visitor_group: "none"` - [ ] Log in as a registered user, verify `visitor_type: "logged_in"` and `visitor_group` shows the correct group name - [ ] With standalone GA4 (no GTM), verify `gtag('set', 'user_properties', ...)` is present in page source - [ ] Disable the toggle, confirm no visitor detection script is rendered - [ ] Disable both GTM and GA4, confirm the toggle is hidden in admin 🤖 Generated with [Claude Code](https://claude.com/claude-code)
jmiller added 1 commit 2026-05-05 20:27:23 +00:00
feat: smart visitor detection for Google Analytics / GTM
Build & Release / Build & Release Pipeline (pull_request) Successful in 15s
Repo Health / Access control (push) Successful in 1s
Joomla Extension CI / Lint & Validate (pull_request) Failing after 3s
Joomla Extension CI / Tests (PHP 8.2) (pull_request) Has been skipped
Repo Health / Access control (pull_request) Successful in 1s
Joomla Extension CI / Tests (PHP 8.3) (pull_request) Has been skipped
Joomla Extension CI / Release Readiness Check (pull_request) Successful in 2s
Repo Health / Release configuration (push) Failing after 3s
Repo Health / Scripts governance (push) Successful in 3s
Repo Health / Repository health (push) Failing after 3s
PR Check / Validate PR (pull_request) Successful in 21s
Repo Health / Release configuration (pull_request) Failing after 3s
Repo Health / Scripts governance (pull_request) Successful in 3s
Repo Health / Repository health (pull_request) Failing after 4s
f49f592cba
Push anonymised visitor properties (login status, user group, page type)
to the dataLayer before GTM/GA4 loads. Sets GA4 user_properties for
persistent session-scoped dimensions. No PII is sent. Default enabled
when GTM or GA4 is active.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
jmiller merged commit bf00286f52 into main 2026-05-05 20:27:30 +00:00
jmiller deleted branch feat/smart-visitor-detection 2026-05-05 20:27:31 +00:00
Sign in to join this conversation.
No Reviewers
No labels
Type
Status
Priority
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: MokoConsulting/MokoOnyx#8