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

Add Web Vitals to Scaffold #130

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open

Add Web Vitals to Scaffold #130

wants to merge 1 commit into from

Conversation

dainemawer
Copy link
Contributor

@dainemawer dainemawer commented Jun 6, 2022

This PR adds Googles Web Vital library to the scaffold.
This work is specifically for new projects that have no way of accurately tracking core web vitals.

web-vitals.js is ~1kb in size, and is rendered directly into the template, not included in the bundle.

Description of the Change

  • Adds a new theme constant: TENUP_WEB_VITAL_TRACKING to hide functionality behind a flag
  • Adds a new file called web-vitals.php in the includes folder
  • Adds 3 new scripts to the footer - one being the web-vitals library, the other is a choice of 3 strategies to follow: custom analytics endpoint, Universal Analytics and Google Analytics 4.

Closes #131

Alternate Designs

Possible Drawbacks

  • There will need to be some further tweaks to the functions depending on the scope and context of the project.
  • Two of the strategies depend on Google Tag Manager being present on the window object.

Verification Process

  1. Set the TENUP_WEB_VITAL_TRACKING to true
  2. Verify that the script tags with id: tenup-web-vital-tracking and send-data-to-endpoint are present in the DOM.

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests passed.

Changelog Entry

Added - Core Web Vitals partial to includes
Added - New Theme Constant: TENUP_WEB_VITAL_TRACKING for flagging the functionality

Credits

Props @dainemawer

@tylercherpak
Copy link

Hey @dainemawer

I think this is great 😄 😄

I have a couple of questions:

  • Can we move the scripts into js files and enqueue them with wp_enqueue_scripts?
  • Does this script itself affect the web vitals score? Does the act of measuring impact performance?

Thanks!

@joesnellpdx
Copy link
Contributor

@dainemawer

I also think this is great!

Per #131, there needs to be updates to the readme and comment guidance in the php files.

Per inline or enqueuing - I feel like inline makes more sense the way you have it, but I'm open for discussion on that.

Also, if opted in - there should be guidance on using the information either for our own racking purposes or sending to 3rd party (via the scripts that are in place).

For clarity - we'd need access to google analytics to see the data? If so, is there a way to maybe update one of our tools (i.e. Support Monitor)?

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

Successfully merging this pull request may close these issues.

Add Web Vital Tracking
5 participants