-
Notifications
You must be signed in to change notification settings - Fork 50
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(analytics): automatically link GA4 with Site Kit #1698
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not able to test the setup of a new GA4. Setting up Site Kit with Analytics creates the GA4 automatically.
Do you recommend a way of testing the "automatic setup" outside of what Site Kit already provides?
* Class extending Site Kit's Module, in order to easily access GA data via | ||
* Site Kit's Analytics Admin service. | ||
*/ | ||
class GoogleSiteKitAnalytics extends Module { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If Site Kit is not installed and active, it throws a fatal error. There should be a proper check before importing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 4768ceb
You'd need a site set up before GA4 was available. You can remove the |
@adekbadek From end user perspective, does this PR simply connects with existing GA 4 property for scenario where site kit is not connected to GA 4? |
@yogeshbeniwal Yes, that's it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Working as expected. Left a non-blocking but important comment below.
* | ||
* @param string $account_id Account ID. | ||
*/ | ||
public function get_ga4_settings( $account_id ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I worry this method, executed on admin_init
, is very optimistic about a third-party structure. If $this->get_service()
fails to return the expected object we'll have a fatal error on every dashboard page.
This could have method_exists()
, property_exists()
and isset()
checks everywhere possible, just to be sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, done in 5885ce2
# [1.84.0-alpha.5](v1.84.0-alpha.4...v1.84.0-alpha.5) (2022-06-10) ### Features * **analytics:** automatically link GA4 with Site Kit ([#1698](#1698)) ([266135f](266135f))
🎉 This PR is included in version 1.84.0-alpha.5 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
# [1.84.0](v1.83.3...v1.84.0) (2022-06-13) ### Bug Fixes * **ads:** resolve conflicts from hotfix merge ([#1685](#1685)) ([8ce12cd](8ce12cd)) * **reader-revenue:** initial order state with total of 0 ([7c30b09](7c30b09)) ### Features * **ads:** handle gam default ad units ([#1654](#1654)) ([321b98e](321b98e)) * **analytics:** automatically link GA4 with Site Kit ([#1698](#1698)) ([266135f](266135f)) * reader registration on donate ([#1655](#1655)) ([5821b57](5821b57)) * remove theme selection from setup wizard ([#1656](#1656)) ([94e4580](94e4580))
🎉 This PR is included in version 1.84.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
All Submissions:
Changes proposed in this Pull Request:
Adds automatic setup of GA4 property with Site Kit, if the property exists in GA. This is a PR to
alpha
, so it's included with the next release.Initially submitted as #1681.
How to test the changes in this Pull Request:
Test on a site with Site Kit configured and Universal GA connected, but GA4 not connected.
master
*/wp-admin/admin.php?page=googlesitekit-settings#/connected-services/analytics
) and observe that GA4 is connectedGA4_MEASUREMENT_ID
in the page source) and GA4 property is hit*** Just one
POST
request withpageview
in payload togoogle-analytics.com
should be sent** So there should be two of these requests, one for the old Universal GA and one for GA4
Other information: