Skip to content

fix(access-control): populate GA4 "group" metadata for anonymous readers#4751

Open
dkoo wants to merge 3 commits into
releasefrom
hotfix/group-metadata-for-anon-readers
Open

fix(access-control): populate GA4 "group" metadata for anonymous readers#4751
dkoo wants to merge 3 commits into
releasefrom
hotfix/group-metadata-for-anon-readers

Conversation

@dkoo
Copy link
Copy Markdown
Contributor

@dkoo dkoo commented May 22, 2026

All Submissions:

Changes proposed in this Pull Request:

Follow-up to #4697 and #4746. Allows the GA4 group param to populate for non-logged-in readers who match an institution via IP access rules.

How to test the changes in this Pull Request:

Prerequisites:

  • NEWSPACK_CONTENT_GATES defined in wp-config.php
  • WooCommerce Memberships plugin deactivated
  • A published Institution (Audience > Access Control > [kebab menu] Institutions) with an IP whitelist access rule
  • Google Site Kit connected with Google Analytics enabled
  1. In an incognito session, without registering or logging in, visit the institution's access URL using an IP that falls in the institution's whitelisted IP range and wait until you get redirected to the homepage with the "Connected to..." success message.
  2. View the page source and confirm that you see the "group": "Institution #####" param appended to the gtag("config") call.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@dkoo dkoo self-assigned this May 22, 2026
@dkoo dkoo requested a review from a team as a code owner May 22, 2026 22:32
Copilot AI review requested due to automatic review settings May 22, 2026 22:32
@dkoo dkoo added the [Status] Needs Review The issue or pull request needs to be reviewed label May 22, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Google Site Kit GA4 integration so the GA4 group custom parameter can be populated for anonymous visitors who match an Institution via IP-based access rules (e.g., after passing /institutional-access and receiving the cache-bypass cookie).

Changes:

  • Pre-populate GA4 group labels with matching Institution IDs even when the current user is not logged in.
  • Adjust early-return behavior in get_user_group_labels() so anonymous users can still receive Institution labels.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread includes/plugins/google-site-kit/class-googlesitekit.php
Comment thread includes/plugins/google-site-kit/class-googlesitekit.php
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 6.41.3-hotfix-group-metadata-for-anon-readers.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@dkoo dkoo changed the base branch from trunk to release May 22, 2026 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Status] Needs Review The issue or pull request needs to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants