Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add GA4 donation events #2326

Merged
merged 3 commits into from
Mar 9, 2023
Merged

feat: add GA4 donation events #2326

merged 3 commits into from
Mar 9, 2023

Conversation

leogermani
Copy link
Contributor

All Submissions:

Changes proposed in this Pull Request:

Connects the Donation events to GA4.

How to test the changes in this Pull Request:

Get the GA4 credentials. You will need your measurement ID and an API secret.

  • api_secret - Required. An API SECRET generated in the Google Analytics UI. To create a new secret, navigate to:
    Admin > Data Streams > choose your stream > Measurement Protocol > Create
  • measurement_id - Required. The measurement ID associated with a stream. Found in the Google Analytics UI under:
    Admin > Data Streams > choose your stream > Measurement ID

Store this info in the database:

wp option set ga4_measurement_id "G-XXXXXXXXXX"
wp option set ga4_api_secret YYYYYYYYYYYYYYYYYYY

Now, let's test:

  1. Make sure RAS is active and that you have a registered reader
  2. Make sure to add this constant to wp-config
define( 'NEWSPACK_LOG_LEVEL', 2 );
define( 'NEWSPACK_EXPERIMENTAL_GA4_EVENTS', true );
  1. Make a donation to the site via the donation block.
  2. Watch the donation_new event being fired in the logs
[NEWSPACK-DATA-EVENTS][Newspack\Data_Events::dispatch]: Dispatching action "donation_new" via Action Scheduler.
  1. Watch the handler being triggered and sending the reader_registered GA event:
[NEWSPACK-DATA-EVENTS][Newspack\Data_Events::handle]: Executing action handlers for "donation_new".
[NEWSPACK-DATA-EVENTS-GA4][Newspack\Data_Events\Connectors\GA4::log]: Event sent - donation_new
  1. Visit the Google Analytics Realtime dashboard
  2. See the donation_new events coming in
  3. Inspect them and see check its attributes to see if the values are correct.

Captura de tela de 2023-03-07 08-37-09

  1. In the admin panel, go to Woocommerce > Subscriptions
  2. Cancel the subscription
  3. See that a donation_subscription_cancelled event will be fired
  4. Check all its metadata
  5. Repeat steps 5 to 13 using both Stripe and Newspack as Reader Revenue platforms

NOTE: referer and popup_id attributes are being added by #2310

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?

@leogermani leogermani added the [Status] Needs Review The issue or pull request needs to be reviewed label Mar 7, 2023
@leogermani leogermani requested a review from a team as a code owner March 7, 2023 12:37
@leogermani leogermani self-assigned this Mar 7, 2023
Copy link
Member

@miguelpeixe miguelpeixe left a comment

Choose a reason for hiding this comment

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

💯

@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 Mar 9, 2023
@leogermani leogermani merged commit a1377a2 into master Mar 9, 2023
@leogermani leogermani deleted the add/ga4-donation-events branch March 9, 2023 20:15
matticbot pushed a commit that referenced this pull request Mar 16, 2023
# [1.108.0-alpha.1](v1.107.1...v1.108.0-alpha.1) (2023-03-16)

### Bug Fixes

* **ads:** proper usage of useEffect cleanup function ([#2335](#2335)) ([58e4c10](58e4c10))
* **cli:** setup config path ([6de5d36](6de5d36))
* **data-events:** mailchimp metadata keys ([#2331](#2331)) ([de82e06](de82e06))
* **modal-checkout:** provide conversion URL for ESP ([feca20d](feca20d))
* only show perfmatters notice if defaults are used ([bdae0b2](bdae0b2))
* post-release merge conflict ([3d03cd2](3d03cd2))
* show handoff to finish Newspack setup only if setup is incomplete ([#2343](#2343)) ([b0a85ef](b0a85ef))
* toggling settings section ([#2349](#2349)) ([87d5218](87d5218))
* **webhooks:** endpoint requests modal label ([#2332](#2332)) ([fd99ff2](fd99ff2))
* **webhooks:** grid layout ([4aa898f](4aa898f))
* **wizards:** broken rendering in WP 6.2 ([a6cef5a](a6cef5a))

### Features

* add GA4 donation events ([#2326](#2326)) ([a1377a2](a1377a2))
* Add GA4 Newsletters subscriptions events ([#2330](#2330)) ([86ffc66](86ffc66))
* Add popups donation events ([#2310](#2310)) ([53e0c4a](53e0c4a))
* **amp-deprecation:** polyfills for amp-img, amp-iframe, amp-fit-text, amp-youtube ([#2308](#2308)) ([7419cd5](7419cd5))
* **health-check:** mark some plugins as supported ([#2329](#2329)) ([c1774e3](c1774e3))
@matticbot
Copy link
Contributor

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

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Mar 20, 2023
# [1.109.0-alpha.1](v1.108.0...v1.109.0-alpha.1) (2023-03-20)

### Bug Fixes

* **ads:** proper usage of useEffect cleanup function ([#2335](#2335)) ([58e4c10](58e4c10))
* **cli:** setup config path ([6de5d36](6de5d36))
* **data-events:** mailchimp metadata keys ([#2331](#2331)) ([de82e06](de82e06))
* **modal-checkout:** provide conversion URL for ESP ([feca20d](feca20d))
* only show perfmatters notice if defaults are used ([bdae0b2](bdae0b2))
* post-release merge conflict ([3d03cd2](3d03cd2))
* show handoff to finish Newspack setup only if setup is incomplete ([#2343](#2343)) ([b0a85ef](b0a85ef))
* toggling settings section ([#2349](#2349)) ([87d5218](87d5218))
* **webhooks:** endpoint requests modal label ([#2332](#2332)) ([fd99ff2](fd99ff2))
* **webhooks:** grid layout ([4aa898f](4aa898f))
* **wizards:** broken rendering in WP 6.2 ([a6cef5a](a6cef5a))

### Features

* add GA4 donation events ([#2326](#2326)) ([a1377a2](a1377a2))
* Add GA4 Newsletters subscriptions events ([#2330](#2330)) ([86ffc66](86ffc66))
* Add popups donation events ([#2310](#2310)) ([53e0c4a](53e0c4a))
* **amp-deprecation:** polyfills for amp-img, amp-iframe, amp-fit-text, amp-youtube ([#2308](#2308)) ([7419cd5](7419cd5))
* **health-check:** mark some plugins as supported ([#2329](#2329)) ([c1774e3](c1774e3))
@matticbot
Copy link
Contributor

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

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Mar 24, 2023
# [1.110.0-alpha.1](v1.109.0...v1.110.0-alpha.1) (2023-03-24)

### Bug Fixes

* **ads:** proper usage of useEffect cleanup function ([#2335](#2335)) ([58e4c10](58e4c10))
* **cli:** setup config path ([6de5d36](6de5d36))
* **data-events:** mailchimp metadata keys ([#2331](#2331)) ([de82e06](de82e06))
* **modal-checkout:** provide conversion URL for ESP ([feca20d](feca20d))
* only show perfmatters notice if defaults are used ([bdae0b2](bdae0b2))
* **perfmatters:** add twitter.com to JS delay list ([34bac52](34bac52))
* post-release merge conflict ([3d03cd2](3d03cd2))
* show handoff to finish Newspack setup only if setup is incomplete ([#2343](#2343)) ([b0a85ef](b0a85ef))
* toggling settings section ([#2349](#2349)) ([87d5218](87d5218))
* **webhooks:** endpoint requests modal label ([#2332](#2332)) ([fd99ff2](fd99ff2))
* **webhooks:** grid layout ([4aa898f](4aa898f))
* **wizards:** broken rendering in WP 6.2 ([a6cef5a](a6cef5a))

### Features

* add GA4 donation events ([#2326](#2326)) ([a1377a2](a1377a2))
* Add GA4 Newsletters subscriptions events ([#2330](#2330)) ([86ffc66](86ffc66))
* Add popup events to GA4 ([#2337](#2337)) ([62c738e](62c738e))
* Add popups donation events ([#2310](#2310)) ([53e0c4a](53e0c4a))
* **amp-deprecation:** polyfills for amp-img, amp-iframe, amp-fit-text, amp-youtube ([#2308](#2308)) ([7419cd5](7419cd5))
* **health-check:** mark some plugins as supported ([#2329](#2329)) ([c1774e3](c1774e3))
@matticbot
Copy link
Contributor

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

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Mar 27, 2023
# [1.110.0](v1.109.0...v1.110.0) (2023-03-27)

### Bug Fixes

* **ads:** proper usage of useEffect cleanup function ([#2335](#2335)) ([58e4c10](58e4c10))
* **cli:** setup config path ([6de5d36](6de5d36))
* **data-events:** mailchimp metadata keys ([#2331](#2331)) ([de82e06](de82e06))
* **modal-checkout:** provide conversion URL for ESP ([feca20d](feca20d))
* only show perfmatters notice if defaults are used ([bdae0b2](bdae0b2))
* **perfmatters:** add twitter.com to JS delay list ([34bac52](34bac52))
* post-release merge conflict ([3d03cd2](3d03cd2))
* show handoff to finish Newspack setup only if setup is incomplete ([#2343](#2343)) ([b0a85ef](b0a85ef))
* toggling settings section ([#2349](#2349)) ([87d5218](87d5218))
* **webhooks:** endpoint requests modal label ([#2332](#2332)) ([fd99ff2](fd99ff2))
* **webhooks:** grid layout ([4aa898f](4aa898f))
* **wizards:** broken rendering in WP 6.2 ([a6cef5a](a6cef5a))

### Features

* add GA4 donation events ([#2326](#2326)) ([a1377a2](a1377a2))
* Add GA4 Newsletters subscriptions events ([#2330](#2330)) ([86ffc66](86ffc66))
* Add popup events to GA4 ([#2337](#2337)) ([62c738e](62c738e))
* Add popups donation events ([#2310](#2310)) ([53e0c4a](53e0c4a))
* **amp-deprecation:** polyfills for amp-img, amp-iframe, amp-fit-text, amp-youtube ([#2308](#2308)) ([7419cd5](7419cd5))
* **health-check:** mark some plugins as supported ([#2329](#2329)) ([c1774e3](c1774e3))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.110.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.

3 participants