• English日本語한국어
  • Log inStart now

Browser monitoring and the PHP agent

With the PHP agent, you can add browser monitoring to your pages either automatically or manually. To enable browser monitoring in the user interface, follow the procedures to install the browser agent. Then follow the procedures in this section to set up the PHP agent.

To use browser monitoring with your PHP agent, ensure you have the latest release. For more information, see the agent installation instructions.

Use auto-instrumentation

To configure the agent to automatically instrument pages with the browser monitoring script, add or edit the auto-instrumentation flag in your INI file. The PHP agent will automatically inject the browser monitoring's JS snippet into your pages.


Auto-instrumentation does not work when the HTTP header field Content-Length is set. To use browser monitoring in this situation, disable auto-instrumentation and manually insert the JavaScript header and footer into your templates.

Manually instrument via agent API

To manually configure browser monitoring, include the appropriate scripts in your pages. The New Relic PHP agent has an API to automatically generate the required JavaScript header and footer in place.


Calls to the PHP agent API are conditional on the newrelic extension being loaded so that the PHP agent is running. If the agent is not running, calls to generate the JavaScript header and footer will result in errors, as the functions will not be defined.

For more information, see:

Manually instrument for various frameworks

This document does not provide detailed procedures to manually insert the browser agent via the agent API. This is because there too many possible ways to construct a framework.

The manual instrumentation examples show how to add instrumentation to frameworks that already support auto-instrumentation. If you are using another framework or modified versions of Drupal or WordPress, be sure to call the API functions for instrumentation at the right place.

  1. Insert the return value of newrelic_get_browser_timing_header() as part of the output page's <head> tag, preferably as the very first thing.
  2. As the very last thing before the closing </body> tag in the document, or as close to it as possible, insert the return value of newrelic_get_browser_timing_footer().

Here are some basic examples.

View Browser data

Once you enable browser monitoring and generate traffic for your app, data will appear in your app's browser Summary page. There is a short delay the first time you start the daemon (or when the PHP agent encounters a new application) while the daemon verifies the settings. After that, the New Relic JavaScript snippet is available.

Disable auto-instrumentation

For how to disable browser monitoring with the PHP agent config, see Browser monitoring config option.

For how to use the API to disable browser monitoring, see newrelic_disable_autorum().

Copyright © 2023 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.