Cloud Platform

Disabling New Relic agent injection

Acquia Support uses New Relic as a tool to help diagnose website performance problems. The New Relic service injects a small JavaScript agent into pages, allowing New Relic to gather data about the end user’s experience. This JavaScript injection may conflict with other JavaScript used on a website or cause validation errors, like the following validation error from Google’s AMP service:

The tag 'script' is disallowed except in specific forms.

New Relic’s documentation provides the newrelic_disable_autorum() method to disable the injection of the New Relic Browser JavaScript agent for the current transaction.

To apply this code to a Drupal website, add the code for your version of Drupal to the bottom of your website’s settings.php file, adjusting [path_to_ignore] to the actual pages or paths you don’t want the New Relic agent to be injected into.

if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '[path_to_ignore]') !== false ) {
  if (extension_loaded('newrelic')) { // Ensure PHP agent is available
    newrelic_disable_autorum();
    }
}

Did not find what you were looking for?

If this content did not answer your questions, try searching or contacting our support team for further assistance.

Acquia Help

Filter by product:

Cloud Platform common questions