Feature Idea: Disabling APM for Google AMP pages

On my site, I have a set of URLs for Google AMP equivalent pages for my blog posts. The New Relic APM PHP Agent is automatically adding a script tag to every page. However, this is not allowed on AMP pages.

How can I prevent the agent from adding the script to specific urls on my site?

New Relic edit

##Vote here for Auto Disable Feature

  • I want this, too
  • I have more info to share (reply below)
  • I have a solution for this

0 voters

We take feature ideas seriously and our product managers review every one when plotting their roadmaps. However, there is no guarantee this feature will be implemented. This post ensures the idea is put on the table and discussed though. So please vote and share your extra details with our team.

I figured out I could do this at the top of the php template for our AMP pages.

if (extension_loaded('newrelic')) {

We’re using Wordpress. If we were logged into the Wordpress Admin then the following worked by itself…


But once we logged out of the Wordpress Admin, then the script was being added again until we added this line also…


where exactly did you add that?

We also now have a general troubleshooting doc on this: https://docs.newrelic.com/docs/browser/new-relic-browser/troubleshooting/google-amp-validator-fails-due-3rd-party-script

Hi there, I’m Jeff Martens and I serve as the Product Manager for New Relic’s Real User Monitoring product, New Relic Browser. We are seeing more use of AMP and as @clangosch pointed out, we now have a page in our docs dedicated to AMP compatibility. The great thing is that you can disable New Relic real user monitoring just for your AMP pages, keeping it on all your standard pages.

We are also looking into how we can make using AMP more seamless for New Relic APM/Browser users, as well as how we might integrate with the Analytics component of the AMP specs. Stay tuned!

In the meantime, let us know if you have any questions or suggestions!

Disabling it automatically would be great. An AMP page should be pretty easy to detect (<html amp) and it is guaranteed to not work, so nobody will disagree with it. That is, unless you find a way to make it amp compatible (through amp-analytics, or so) but you still need to detect that then.

I’ll go ahead and put in a feature request for you regarding automatic disabling—thanks for pitching in and thanks for sharing your input! We love hearing our customers needs within our products. :blush:

A post was split to a new topic: The code doesn’t work for my PHP pages

New Relic edit:
poll redacted in order to keep consistency throughout all the feature ideas in this community

Hey there @tzickell! I wanted to get some more information from you since it looks like there wasn’t much context provided in your last post :arrow_up:

Please feel free to edit your recent post of reply below here with any questions, workarounds, etc. that you wish to discuss. Thanks!

have someone tried this?

// If you use both the Exclude and Attribute elements
// the Exclude element must be listed first.


Can you suggest the same for HTML page also. How can I stop disable Newrelick for my AMP HTML


I have the same problem. Has anyone found a solution to solve this problem ?

Hi there @sebastien6,

You should be able to disable automatic Browser injection for Google AMP pages by using the following PHP agent API call:


Here’s the documentation on that:

This call disables automatic injection of the New Relic Browser JavaScript agent for the current transaction. Call as early as possible.

Is that something you’ve tried yet? If that hasn’t worked for you, let me know, and if you can include a snippet of how you’re making the call that will help us look into it.


1 Like