Skip to content

Conversation

@dkoo
Copy link
Contributor

@dkoo dkoo commented Apr 7, 2025

All Submissions:

Changes proposed in this Pull Request:

Deprecates back-end GA4 events, which we've found to be too inaccurate to be useful, possibly due to various caching layers readers might encounter in production sites.

Migrates reader_registered and reader_logged_in events to the front-end, although not with all params that were included on back-end equivalents.

Also fixes a bug where registering via a Registration block directly inside a content gate (as opposed to an auth modal triggered by a link in the content gate) fails to trigger an auto page reload after successful registration.

Also migrates all content gate GA events to the front-end. Note that the parameters passed to these events and some of the values for these parameters differ from the back-end events they replace, notably:

  • action_type=paid_membership - This will now be action_type=checkout_button, which matches the parameter value given by modal checkout interaction events. This should make it easier to track conversion rates by filtering events by action_type=checkout_button.
  • Donation interactions from within content gates are now tracked with their own parameters.

All events and their parameters are documented in a new README file.

Requires Automattic/newspack-blocks#2103, Automattic/newspack-newsletters#1800, and Automattic/newspack-popups#1424

Supersedes #3805. Closes 1200550061930446/as/1209870698187233.

How to test the changes in this Pull Request:

Content gate events

  1. Check out this branch, fix(content-gating): account for block visibility in GA4 params newspack-blocks#2103, feat(reader-data): dispatch reader data activity when reader registered newspack-newsletters#1800, and fix: pass popup ID param through order newspack-popups#1424.
  2. Set up a site with Google Analytics + RAS + Woo Memberships with a metered regwall + paywall setup (DM me for instructions on how). The important thing is that the Non-Member Content block shown to anonymous readers contains one or more of the Donate, Registration, or Checkout Button blocks, and the Member Content block shown to registered readers contains the others of those blocks.
  3. As an anonymous reader, visit a post that will show the regwall part of the content gate. In Dev Tools > Network look for a collect XHR request that contains a payload that looks like this:
Screenshot 2025-04-08 at 5 04 02 PM

Note the highlighted part of the payload, and confirm that the gate_has_donation_block, gate_has_registration_block, and gate_has_checkout_button params are accurately set to yes or no based on which of those blocks are visible within the content gate. Also note other parameters as described in the README and confirm they're accurate.

  1. Register (or log in) via the Registration block inside the content gate to pass the regwall. Confirm that after a couple of seconds, the page reloads automatically to show the full article content.
  2. In Dev Tools > Network look for the collect XHR requests with event name reader_registered or reader_logged_in, and confirm their parameters are accurate.
  3. View more posts until you see the paywall content gate. In Dev Tools > Network look for the collect XHR requests and confirm that their parameters are accurate.
  4. Start modal checkouts from Donation and Checkout Blocks inside the content gate. Again, look for the collect requests and confirm their parameters are accurate.
  5. Dismiss the modal checkouts and complete them, and confirm that np_modal_checkout_interaction events are fired for these interactions, and that all events contain a gate_post_id with the content gate's post ID, indicating these checkouts originated from the content gate.
  6. Review the src/memberships-gate/README.md file and confirm that it accurately describes the events and their params.

registered & logged_in events

  1. Register new reader accounts via the Registration block, Newsletter Subscription Form block, and the auth modal. For the blocks, register accounts via block instances both inside and not inside Campaigns prompts and content gates (note: for the latter you may need to stop the auto-refresh from happening or watch real-time reports in Google Analytics to see this event). Confirm that all registrations result in reader_registered GA events being fired, and that the ones from inside prompts include a popup_id param.
  2. Log into an existing account via the auth modal and confirm that it fires a reader_logged_in GA event.
  3. Log into an existing account via a magic link and confirm that a GA event fires on the first page view after authenticating.
  4. Review the src/reader-activation/README.md file and confirm that it accurately describes the events and their params.

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 added the [Status] Needs Review The issue or pull request needs to be reviewed label Apr 8, 2025
@dkoo dkoo marked this pull request as ready for review April 8, 2025 23:13
@dkoo dkoo requested a review from a team as a code owner April 8, 2025 23:13
Copy link
Contributor

@leogermani leogermani left a comment

Choose a reason for hiding this comment

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

Almost everything works, the only event I couldn't see was the "action=dismiss". Is it a thing?

Other than that left a comment and let's see if we can align how this and popups measurements work as much as possible

@dkoo
Copy link
Contributor Author

dkoo commented Apr 10, 2025

@leogermani 6f50aa5 and c1abda3 add front-end GA events for reader registrations and logins, as well as a README file describing their params. These events are named the same as the equivalent deprecated back-end events, but don't contain as much data in their params. We can explore adding more data in a separate PR, if needed.

@dkoo dkoo requested a review from leogermani April 10, 2025 23:15
@dkoo
Copy link
Contributor Author

dkoo commented Apr 10, 2025

Almost everything works, the only event I couldn't see was the "action=dismiss". Is it a thing?

For np_gate_interaction events, action=dismissed events are only fired when dismissing the auth modal if it was opened from a page containing a content gate. If dismissing a modal checkout, a np_modal_checkout_interaction event with action=dismissed is fired, and it will include the gate_id param if the checkout started from a content gate.

@dkoo dkoo changed the title fix(content-gating): fixes for GA4 events fix(analytics): migrate back-end GA4 events to front-end Apr 10, 2025
@leogermani
Copy link
Contributor

A few comments questions from my lates tests:

  • the modal_checkout_interaction form_submission_success event doesn't include the gate id. I can only see the gate_id up until form_submission
  • I only see the additional params like is_logged_in, is_reader etc, for the np_gate_interaction, but not for the modal_checkout_interaction. Is this expected?
  • The refresh after registration worked well, but it didn't refresh the page after a subscription purchase that unlocked the membership.

FInally, I didin't see the reader_registered event being fired after a registration from within the content gate. I thought it could be because of the page redirect, but reading the PR description maybe this is expected?

I'd say that if we can't make sure that we capture ALL reader registrations from all the possible methods, maybe we shouldn't add this event just yet. Same for logged_in... it will generate incomplete stats

@dkoo
Copy link
Contributor Author

dkoo commented Apr 16, 2025

@leogermani this is ready for another review based on the latest discussion:

  • No more form_submission_success actions for np_gate_interaction events—the form_submission actions will represent a successful conversion intent
  • Improved logic for the auto-reload: the page will auto-reload on gated content only when:
    • Successfully registering a new account, logging into an existing account, or completing a modal checkout transaction
    • Only once all modal overlays have been closed

@github-actions github-actions bot added [Status] Approved The pull request has been reviewed and is ready to merge and removed [Status] Needs Review The issue or pull request needs to be reviewed labels Apr 17, 2025
@dkoo dkoo merged commit 7e18628 into trunk Apr 18, 2025
7 checks passed
@dkoo dkoo deleted the fix/ga4-content-gate-events branch April 18, 2025 15:51
@github-actions
Copy link

Hey @dkoo, good job getting this PR merged! 🎉

Now, the needs-changelog label has been added to it.

Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label.

If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label.

Thank you! ❤️

matticbot pushed a commit that referenced this pull request Apr 23, 2025
# [6.5.0-alpha.1](v6.4.4...v6.5.0-alpha.1) (2025-04-23)

### Bug Fixes

* add white background to Newspack admin screens ([#3909](#3909)) ([4c8409e](4c8409e))
* allow guest contributors to have empty archives ([#3902](#3902)) ([af8bed9](af8bed9))
* **analytics:** migrate back-end GA4 events to front-end ([#3895](#3895)) ([7e18628](7e18628))
* **auth-form:** check user before is_user_reader() call ([#3944](#3944)) ([1cbb760](1cbb760))
* avoid warning for network event ([#3942](#3942)) ([60d0aa3](60d0aa3))
* **bylines:** avoid rerendering of editable area ([#3896](#3896)) ([9fdf659](9fdf659))
* **bylines:** custom edited state for modal ([#3919](#3919)) ([2a1a800](2a1a800))
* **bylines:** get CAP data from the plugin's store ([#3906](#3906)) ([0745113](0745113))
* **corrections:** Limit CPT to posts only ([#3927](#3927)) ([1d49c39](1d49c39))
* **corrections:** Use Corrections Archive template by default ([#3929](#3929)) ([c4c1925](c4c1925))
* **email-change:** ensure success and error messages persist after redirect ([#3913](#3913)) ([caf82a5](caf82a5))
* **email-change:** improve messaging for in-progress or expired change requests ([#3886](#3886)) ([02d2ea0](02d2ea0))
* **email-change:** typo in variable name ([#3941](#3941)) ([941dc21](941dc21))
* **google-login:** handle google oauth disabled state in the editor ([#3946](#3946)) ([0f9f7c6](0f9f7c6))
* hide campaigns menu when the Newspack Campaigns plugin is not activated ([#3922](#3922)) ([adcc21f](adcc21f))
* make front end not dependent on coauthors plus ([#3905](#3905)) ([dc96e5b](dc96e5b))
* **otp-input:** enhance OTP input handling for clipboard ([#3898](#3898)) ([a56328b](a56328b))
* reinstate the Add New Newsletter link in the admin menu ([#3926](#3926)) ([1c8c7d7](1c8c7d7))
* remove extra space above empty help text ([#3904](#3904)) ([6a4fe4f](6a4fe4f))
* remove import and route for Suppression ([#3894](#3894)) ([a2034e7](a2034e7))
* **setup-wizard:** prevent Yoast redirect ([#3940](#3940)) ([3461b5f](3461b5f))

### Features

* **auth:** OTP autocomplete integration ([#3888](#3888)) ([5a1d7a8](5a1d7a8))
* **bylines:** get post byline authors ([#3911](#3911)) ([17942a2](17942a2))
* **bylines:** useAuthorTokens() hook with user entity validation ([#3907](#3907)) ([3d1feee](3d1feee))
* **email-change:** allow old email to cancel email change only, not confirm ([#3912](#3912)) ([92413e3](92413e3))
* **ga4:** np_newsletter_subscribed event upon front-end signup ([#3938](#3938)) ([2295277](2295277))
* **ras-newsletter:** Newsletters list progressive disclosure ([#3887](#3887)) ([53f4eed](53f4eed))
* **reader-auth:** send WP login reminder email to non-reader accounts ([#3796](#3796)) ([d1af25e](d1af25e)), closes [#3823](#3823)
* **scss:** export colors as module for JS consumption ([#3910](#3910)) ([81da8f0](81da8f0))
* **segments:** add filter for device segment ([#3880](#3880)) ([d465726](d465726))
* update colors and add all design system variables ([#3882](#3882)) ([6ee8e30](6ee8e30))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 6.5.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request May 8, 2025
# [6.6.0-alpha.1](v6.5.0...v6.6.0-alpha.1) (2025-05-08)

### Bug Fixes

* add white background to Newspack admin screens ([#3909](#3909)) ([4c8409e](4c8409e))
* allow guest contributors to have empty archives ([#3902](#3902)) ([af8bed9](af8bed9))
* **analytics:** migrate back-end GA4 events to front-end ([#3895](#3895)) ([7e18628](7e18628))
* **auth-form:** check user before is_user_reader() call ([#3944](#3944)) ([1cbb760](1cbb760))
* avoid warning for network event ([#3942](#3942)) ([60d0aa3](60d0aa3))
* **bylines:** avoid rerendering of editable area ([#3896](#3896)) ([9fdf659](9fdf659))
* **bylines:** custom edited state for modal ([#3919](#3919)) ([2a1a800](2a1a800))
* **bylines:** get CAP data from the plugin's store ([#3906](#3906)) ([0745113](0745113))
* **corrections:** Limit CPT to posts only ([#3927](#3927)) ([1d49c39](1d49c39))
* **corrections:** Use Corrections Archive template by default ([#3929](#3929)) ([c4c1925](c4c1925))
* **email-change:** ensure success and error messages persist after redirect ([#3913](#3913)) ([caf82a5](caf82a5))
* **email-change:** improve messaging for in-progress or expired change requests ([#3886](#3886)) ([02d2ea0](02d2ea0))
* **email-change:** typo in variable name ([#3941](#3941)) ([941dc21](941dc21))
* **ga4:** ensure gate_post_id and newspack_popup_id are passed to activities ([#3956](#3956)) ([fadaa4d](fadaa4d))
* **google-login:** handle google oauth disabled state in the editor ([#3946](#3946)) ([0f9f7c6](0f9f7c6))
* hide campaigns menu when the Newspack Campaigns plugin is not activated ([#3922](#3922)) ([adcc21f](adcc21f))
* make front end not dependent on coauthors plus ([#3905](#3905)) ([dc96e5b](dc96e5b))
* **newsletters-wizard:** remove advertisers menu item ([#3948](#3948)) ([2fddbd6](2fddbd6))
* **otp-input:** enhance OTP input handling for clipboard ([#3898](#3898)) ([a56328b](a56328b))
* reinstate the Add New Newsletter link in the admin menu ([#3926](#3926)) ([1c8c7d7](1c8c7d7))
* remove extra space above empty help text ([#3904](#3904)) ([6a4fe4f](6a4fe4f))
* remove import and route for Suppression ([#3894](#3894)) ([a2034e7](a2034e7))
* **setup-wizard:** prevent Yoast redirect ([#3940](#3940)) ([3461b5f](3461b5f))

### Features

* **auth:** OTP autocomplete integration ([#3888](#3888)) ([5a1d7a8](5a1d7a8))
* **bylines:** get post byline authors ([#3911](#3911)) ([17942a2](17942a2))
* **bylines:** useAuthorTokens() hook with user entity validation ([#3907](#3907)) ([3d1feee](3d1feee))
* **email-change:** allow old email to cancel email change only, not confirm ([#3912](#3912)) ([92413e3](92413e3))
* **ga4:** np_newsletter_subscribed event upon front-end signup ([#3938](#3938)) ([2295277](2295277))
* **ras-newsletter:** Newsletters list progressive disclosure ([#3887](#3887)) ([53f4eed](53f4eed))
* **reader-auth:** send WP login reminder email to non-reader accounts ([#3796](#3796)) ([d1af25e](d1af25e)), closes [#3823](#3823)
* **scss:** export colors as module for JS consumption ([#3910](#3910)) ([81da8f0](81da8f0))
* **segments:** add filter for device segment ([#3880](#3880)) ([d465726](d465726))
* update colors and add all design system variables ([#3882](#3882)) ([6ee8e30](6ee8e30))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 6.6.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request May 14, 2025
# [6.6.0](v6.5.1...v6.6.0) (2025-05-14)

### Bug Fixes

* add white background to Newspack admin screens ([#3909](#3909)) ([4c8409e](4c8409e))
* allow guest contributors to have empty archives ([#3902](#3902)) ([af8bed9](af8bed9))
* **analytics:** migrate back-end GA4 events to front-end ([#3895](#3895)) ([7e18628](7e18628))
* **auth-form:** check user before is_user_reader() call ([#3944](#3944)) ([1cbb760](1cbb760))
* avoid warning for network event ([#3942](#3942)) ([60d0aa3](60d0aa3))
* **bylines:** avoid rerendering of editable area ([#3896](#3896)) ([9fdf659](9fdf659))
* **bylines:** custom edited state for modal ([#3919](#3919)) ([2a1a800](2a1a800))
* **bylines:** get CAP data from the plugin's store ([#3906](#3906)) ([0745113](0745113))
* **corrections:** Limit CPT to posts only ([#3927](#3927)) ([1d49c39](1d49c39))
* **corrections:** Use Corrections Archive template by default ([#3929](#3929)) ([c4c1925](c4c1925))
* **email-change:** ensure success and error messages persist after redirect ([#3913](#3913)) ([caf82a5](caf82a5))
* **email-change:** improve messaging for in-progress or expired change requests ([#3886](#3886)) ([02d2ea0](02d2ea0))
* **email-change:** typo in variable name ([#3941](#3941)) ([941dc21](941dc21))
* **ga4:** ensure gate_post_id and newspack_popup_id are passed to activities ([#3956](#3956)) ([fadaa4d](fadaa4d))
* **google-login:** handle google oauth disabled state in the editor ([#3946](#3946)) ([0f9f7c6](0f9f7c6))
* hide campaigns menu when the Newspack Campaigns plugin is not activated ([#3922](#3922)) ([adcc21f](adcc21f))
* make front end not dependent on coauthors plus ([#3905](#3905)) ([dc96e5b](dc96e5b))
* **newsletters-wizard:** remove advertisers menu item ([#3948](#3948)) ([2fddbd6](2fddbd6))
* **otp-input:** enhance OTP input handling for clipboard ([#3898](#3898)) ([a56328b](a56328b))
* reinstate the Add New Newsletter link in the admin menu ([#3926](#3926)) ([1c8c7d7](1c8c7d7))
* remove extra space above empty help text ([#3904](#3904)) ([6a4fe4f](6a4fe4f))
* remove import and route for Suppression ([#3894](#3894)) ([a2034e7](a2034e7))
* **setup-wizard:** prevent Yoast redirect ([#3940](#3940)) ([3461b5f](3461b5f))

### Features

* **auth:** OTP autocomplete integration ([#3888](#3888)) ([5a1d7a8](5a1d7a8))
* **bylines:** get post byline authors ([#3911](#3911)) ([17942a2](17942a2))
* **bylines:** useAuthorTokens() hook with user entity validation ([#3907](#3907)) ([3d1feee](3d1feee))
* **email-change:** allow old email to cancel email change only, not confirm ([#3912](#3912)) ([92413e3](92413e3))
* **email-change:** remove env constant requirement ([#3943](#3943)) ([f04e58f](f04e58f))
* **ga4:** np_newsletter_subscribed event upon front-end signup ([#3938](#3938)) ([2295277](2295277))
* **ras-newsletter:** Newsletters list progressive disclosure ([#3887](#3887)) ([53f4eed](53f4eed))
* **reader-auth:** send WP login reminder email to non-reader accounts ([#3796](#3796)) ([d1af25e](d1af25e)), closes [#3823](#3823)
* **scss:** export colors as module for JS consumption ([#3910](#3910)) ([81da8f0](81da8f0))
* **segments:** add filter for device segment ([#3880](#3880)) ([d465726](d465726))
* update colors and add all design system variables ([#3882](#3882)) ([6ee8e30](6ee8e30))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 6.6.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released on @alpha released [Status] Approved The pull request has been reviewed and is ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants