Request Metrics Evergreen

Introducing Request Metrics Evergreen

Get fast performance scores with no website changes!

WordPress Integration

Request Metrics integrations easily with WordPress to monitor real user performance, capture important events, and understand your user experience. You can automate the installation with our WordPress Plugin, or integrate it manually.

WordPress Plugin

The Request Metrics WordPress Plugin extends the WordPress admin UI with a “Request Metrics” section that allows you to configure your website token and quickly link out to your Performance Dashboard.

Once configured, the plugin will place the Request Metrics install snippet on all of your pages, along with a Custom URL Group that matches the page template or post type. Your Request Metrics reports will be grouped to match the templates you expect in WordPress

WordPress Custom Grouping
WordPress Custom Grouping

The plugin is aware of WooCommerce and will send page grouping information based on stores, collections, products, and checkout.

Installing the Plugin

  1. Download the ZIP file of our latest release from our GitHub Repository.
  2. Extract the request-metrics directory to your computer
  3. Upload the request-metrics directory to the /wp-content/plugins/ directory
  4. Activate the plugin in the Plugin dashboard
  5. Visit Request Metrics > Settings in your Admin and add your website token.
WordPress Plugin UI
WordPress Plugin UI

The Request Metrics WordPress Plugin is open source and available on GitHub.

Manual Integration

You can install Request Metrics on your WordPress site without using our plugin by adding the JavaScript snippet directly. This can be done by modifying your theme’s functions.php file, or by installing a generic plugin like WPCode.

Installing Request Metrics in Your Theme

  1. Open your WordPress Admin and go to “Tools” > “Theme File Editor”.
  2. From the right-side list of files, select “Theme Functions (functions.php)”
  3. Add the following code to that file:
function rm_install_snippet() {
    ?>
<!-- Request Metrics -->
<script>
  (function(t,e,n,r){function a(){return e&&e.now?e.now():null}if(!n.version){n._events=[];n._errors=[];n._metadata={};n._urlGroup=null;window.RM=n;n.install=function(e){n._options=e;var a=t.createElement("script");a.async=true;a.crossOrigin="anonymous";a.src=r;var o=t.getElementsByTagName("script")[0];o.parentNode.insertBefore(a,o)};n.identify=function(t,e){n._userId=t;n._identifyOptions=e};n.sendEvent=function(t,e){n._events.push({eventName:t,metadata:e,time:a()})};n.setUrlGroup=function(t){n._urlGroup=t};n.track=function(t,e){n._errors.push({error:t,metadata:e,time:a()})};n.addMetadata=function(t){n._metadata=Object.assign(n._metadata,t)}}})(document,window.performance,window.RM||{},"https://cdn.requestmetrics.com/agent/current/rm.js");
  RM.install({
      token: "your:token"
  });
</script>
    <?php
}
add_action('wp_head', 'rm_install_snippet');

Save the file and Request Metrics will be added your theme for all pages.

Installing Request Metrics with WPCode (Insert Headers and Footers)

Many WordPress sites use WPCode (formerly “Insert Headers and Footers”) to manage custom code snippets. To install Request Metrics with WPCode, follow these steps:

  1. Open your WordPress Admin and go to “Code Snippets” > “Add Snippet”
  2. Select “Add Your Custom Code”
  3. Add the title “Request Metrics” and paste the following code into an “HTML Snippet”
<!-- Request Metrics -->
<script>
  (function(t,e,n,r){function a(){return e&&e.now?e.now():null}if(!n.version){n._events=[];n._errors=[];n._metadata={};n._urlGroup=null;window.RM=n;n.install=function(e){n._options=e;var a=t.createElement("script");a.async=true;a.crossOrigin="anonymous";a.src=r;var o=t.getElementsByTagName("script")[0];o.parentNode.insertBefore(a,o)};n.identify=function(t,e){n._userId=t;n._identifyOptions=e};n.sendEvent=function(t,e){n._events.push({eventName:t,metadata:e,time:a()})};n.setUrlGroup=function(t){n._urlGroup=t};n.track=function(t,e){n._errors.push({error:t,metadata:e,time:a()})};n.addMetadata=function(t){n._metadata=Object.assign(n._metadata,t)}}})(document,window.performance,window.RM||{},"https://cdn.requestmetrics.com/agent/current/rm.js");
  RM.install({
      token: "your:token"
  });
</script>

Save and activate the snippet.

Did you like this?
Found a mistake? Let us know!