# New Relic

URL: https://docs.ablyft.com/developers/integrations/new-relic/

> Add the experiment and variation a visitor saw to the data of the New Relic browser agent, so you can query it with NRQL.



ABlyft has a built-in New Relic integration. Once you switch it on, ABlyft sets four custom attributes on the New Relic
browser agent each time a visitor sees an experiment. You can then filter and compare page views, errors and
performance by experiment and variation in New Relic.

## What you need

* The New Relic browser agent is installed on the pages where your experiments run.

## Activate the integration

1. Open **Project → Integrations**.
2. On the **New Relic** card, switch the toggle from **Not active** to **Activated** and confirm.

ABlyft then republishes the project. There are no further settings.

## Where you see the data in New Relic

Trigger: **Experiment viewed**. ABlyft sends the data every time the experiment runs for the visitor. If the tool loads slightly later, ABlyft tries again for a short time.

* `experimentId`: ID of the experiment
* `experimentName`: name of the experiment
* `variationId`: ID of the variation
* `variationName`: name of the variation

Need a different format? [Build a custom integration](https://docs.ablyft.com/developers/integrations/custom-integrations/).

New Relic adds the attributes to the events the browser agent reports afterwards, for example `PageView`,
`BrowserInteraction`, `AjaxRequest` and `JavaScriptError`. Query them with NRQL, for example:

```sql
SELECT count(*) FROM PageView FACET variationName WHERE experimentName = '<experiment name>'
```

The attributes stay on the events until the page is reloaded.

> **Good to know:** A custom attribute only lands on the `PageView` event if it is set before the window load event. If the experiment runs later, the attributes appear on later events of the page.

## Check the setup

1. Open a page with a running experiment, in a variation you are bucketed into.
2. In New Relic, run an NRQL query on `PageView` or `BrowserInteraction` that selects `experimentName` and
   `variationName`, and check that your values appear.

## Notes

> **Consent and tracking:** The integration does not run when tracking is disabled for the visitor (opt-out or Do Not Track). The New Relic
> browser agent may need its own consent category in your consent tool.

[New Relic documentation](https://docs.newrelic.com/docs/browser/new-relic-browser/browser-apis/setcustomattribute/)

