• EnglishEspañol日本語한국어Português
  • Log inStart now

Browser monitoring and the PHP agent

By default, the PHP agent automatically adds browser monitoring to your application's web pages. In this automated process, the PHP agent injects the browser agent JavaScript snippet into your webpages. This means you get front-end browser performance monitoring without needing to manually insert the JavaScript snippet into your page's head element.

You can enable or disable auto-instrumentation in your PHP agent config file, or you can use the PHP agent API to manually configure browser monitoring.

Use or disable auto-instrumentation

By default, the PHP agent automatically injects the browser monitoring's JavaScript snippet into your pages. To change this setting, edit the newrelic.browser_monitoring.auto_instrument setting in your INI file.


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 © 2024 New Relic Inc.

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