+1 (617) 7782998 |

Add Instrumentation

PageSpeed real time user monitoring

We will soon be launching our service where you can point the beacons to us for visualisation of the data:
PageSpeed Real Time User Monitoring.

Add Instrumentation will make PageSpeed inject two small blocks of JavaScript, to send beacons to your server or a server of your choise for reporting extensive timings from the server and browsers with regard to loading and rendering.

How it works

An empty HTML file passed through the add_instrumentation filter will come out like this (the inserted whitespace is for documentation readability):

    <script type='text/javascript'>
      window.mod_pagespeed_start = Number(new Date());
    <script type='text/javascript'>
      function g(){
        new Image().src = '/mod_pagespeed_beacon?ets=load:'
          + (Number(new Date())-window.mod_pagespeed_start);
      var f = window.addEventListener;
      if (f) {
      } else {
        if (f) {


You can see the filter in action here.


The first script tag is inserted at the beginning of the document's <head>. It simply records the current time in a global variable. This is placed as early in the document as possible in order to best approximate the beginning of the page load.

The second script tag is inserted at the end of the document's <body>, so as to minimally interfere with page rendering. It registers a listener for the page's onLoad event; this listener computes the total time since the first script tag ran, and sends the result back to the server asynchronously by using a fake Image object. This technique should work on most modern browsers. [1].

The add_instrumentation filter sends a beacon after the page onload handler is called. The user might navigate to a new URL before this. If you enable the following directive, the beacon is sent as part of an onbeforeunload handler, for pages where navigation happens before the onload event.

For PageSpeed on IIS and PageSpeed on ATS

pagespeed ReportUnloadTime on
By default, the target of the asynchronous callback is the relative URL "/pagespeed_beacon". PageSpeed handles these results itself and simply returns "204 No Content" which should cause minimal disruption for the client. It also records the number of callbacks, and the total of their onLoad times, in the statistics "page_load_count" and "total_page_load_ms". These are visible on the PageSpeed statistics page (which, by default, is only viewable from the server's localhost). You can divide total_page_load_ms by page_load_count to get the average onLoad time for your site.

You can change the location of the beacon to a different path (or even a different server) using the BeaconUrl directive. For example:

For PageSpeed on IIS and PageSpeed on ATS

pagespeed BeaconUrl "/my/path/to/beacon"

Beaconed data by Add Instrumentation

parameter type(unit) optional description source
exptid string yes, no experiment when not present experiment id server
hft int(ms) yes, response was from cache when not present header fetch time taken server
ft int(ms) yes, response was from cache when not present fetch time taken server
s_ttfb int(ms) yes, response was from cache when not present server side time to first byte server
rc int yes, 200 when not present response header status code server
id ? ? request_context->request_id() server
ets string ('load' or 'unload') no event used to submit the beacon client
rload int(ms?) yes page load time (XXX) client
ronbeforeunload int(ms) yes(XXX) page load time (XXX) client
nav int yes time on page(??) client(nav timing API)
dns int yes dns resolve time client(nav timing API)
req_start int yes https CONNECT time client(nav timing API)
ttfb int yes time to first byte client(nav timing API)
dwld int yes response download time client(nav timing API)
dom_c int yes dom content loaded time client(nav timing API)
nt int yes navigation type (?) client(nav timing API)
fp int yes first paint time client(nav timing API)
afd int(µs) yes average request duration client(window.performance)
nfd int(µs) yes total number of requests client(window.performance)
mfd int(µs) yes max request duration client(window.performance)
act int(µs) yes average connect duration client(window.performance)
nct int(µs) yes number of connections made client(window.performance)
adt int(µs) yes average domain lookup time client(window.performance)
ndt int(µs) yes number of domain lookups client(window.performance)
abt int(µs) yes average requestStart-fetchStart client(window.performance)
nbt int(µs) yes number of requests used to average ^^ client(window.performance)
attfb int(µs) yes average time to first byte client(window.performance)
nttfb int(µs) yes number of requests used to average ^^ client(window.performance)
rit_css int(µs) yes number of css resources client(window.performance)
rit_link int(µs) yes number of link resources client(window.performance)
rit_script int(µs) yes number of script resources client(window.performance)
rit_image int(µs) yes number of image resources client(window.performance)
ifr int(1/0) yes 1 if the document sending the beacon was an (i)frame client(pagespeed clientside instrumentation)
nrp int no number of prefetched resources client(pagespeed clientside instrumentation)
htmlAt int no ? ?
bcsi ? ? ? panelloader?
ccis int yes total critical inlined size client(pagespeed clientside instrumentation)
cces int yes total critical external size client(pagespeed clientside instrumentation)
ccos int yes total overhead size client(pagespeed clientside instrumentation)
ccrl int yes number of replaced links client(pagespeed clientside instrumentation)
ccul int yes number of unreplaced links client(pagespeed clientside instrumentation)
extraParams_ ? ? ? client(pagespeed clientside instrumentation)
ref url yes document.referrer contents client(pagespeed clientside instrumentation)
url url yes url used to serve the page (as seen by pagespeed serverside - XXX)


For PageSpeed on IIS and PageSpeed on ATS

pagespeed EnableFilters add_instrumentation

pagespeed DisableFilters add_instrumentation

Risk Classification


Examples that demonstrate optimization in real time are available here.

PageSpeed optimization, powered by the official Google PageSpeed SDK

Share View Comments
Some content on this website represents a modified version of the official Google PageSpeed documentation