Skip to content

Instantly share code, notes, and snippets.

@coopr
Last active August 29, 2015 14:11
Show Gist options
  • Save coopr/434707d03bf92adc9e8d to your computer and use it in GitHub Desktop.
Save coopr/434707d03bf92adc9e8d to your computer and use it in GitHub Desktop.
New Relic Browser - Current JS

The current New Relic Browser Pro loader and Browser Lite loader are available from New Relic's CDN. These scripts should be downloaded, and inserted into an inline script tag in the HTML as close to the top of the HEAD as possible, but after any position-sensitive META tags (X-UA-Compatible and charset).

The Browser Pro loader is required for New Relic Browser Pro monitoring, and it also supports Browser Lite monitoring, while the Browser Lite loader supports only Browser Lite monitoring. The Browser Pro loader is larger. If in doubt, use the Browser Pro loader. Use the Browser Lite loader only if you are certain that Browser Pro monitoring has not, and will not, be enabled (either via New Relic's UI or via New Relic's Partner API)

The Browser Application ID and Browser Monitoring Key then need to be set, anywhere after the script is inserted, before the 'load' event.

The ID and Key are available from within New Relic's UI, or via API.

NREUM.info = { applicationID: "your-application-id",
               licenseKey: "your-browser-license-key" // Note this different than your APM key
             };

In the context of a simple html page the New Relic Browser JS should look like this:

<html>
  <head>
    <meta charset='utf-8'>
    <script type="text/javascript">
      //!!INSERT JS FETCHED FROM https://js-agent.newrelic.com/nr-loader-full-current.min.js or https://js-agent.newrelic.com/nr-loader-rum-current.min.js HERE!!
      NREUM.info = { applicationID: "your-application-id",
                     licenseKey: "your-browser-license-key" // Note this different than your APM key
                   }; 
    </script>
    <script type="text/javascript">
      // All other JS here and below, but not above
    </script>
    <title>My Application</title>
  </head>
  <body>
    Hello World!
  </body>
</html> 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment