---
title: newrelic_get_browser_timing_header (PHP agent API)
source: https://docs.newrelic.com/docs/apm/agents/php-agent/php-agent-api/newrelic_get_browser_timing_header
---

## Syntax

```php
newrelic_get_browser_timing_header([bool $include_tags])
```

Returns a browser monitoring snippet to inject in the head of your HTML output.

## Description

Returns a JavaScript string to inject in the `<head>` of your HTML output. Use this call with [`newrelic_get_browser_timing_footer`](https://docs.newrelic.com/docs/agents/php-agent/php-agent-api/newrelic_get_browser_timing_footer) to manually add browser monitoring to a webpage. If possible, New Relic recommends instead enabling browser monitoring via the New Relic UI or copy/pasting the JavaScript snippet. For instructions on using these options, see [browser monitoring and PHP](https://docs.newrelic.com/docs/agents/php-agent/features/page-load-timing-php).

> #### 💡 TIP
>
> Compare [`newrelic_disable_autorum`](https://docs.newrelic.com/docs/agents/php-agent/php-agent-api/newrelic_disable_autorum), which **disables** the browser script on a page.

## Parameters

| Parameter              | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `$include_tags` _bool_ | Optional. Defaults to `true`. If `true` or omitted, the JavaScript string is enclosed in a `<script>` element for easy inclusion into the page's HTML. If `false`, returns the raw JavaScript string without `<script>` tags. This is useful if you need to add custom attributes to the script tag, such as `nonce` for Content Security Policy (CSP). For an example, see [Add custom attributes such as nonce](https://docs.newrelic.com/docs/apm/agents/php-agent/features/browser-monitoring-php-agent/#nonce-attribute). |

## Return values

Returns the browser agent's JavaScript header string.

## Examples

### Instrument a webpage [#webpage]

```php
function example(){
    if (extension_loaded('newrelic')) { // Ensure PHP agent is available
        $newrelic_header = newrelic_get_browser_timing_header();
    }
    
    // Output to page
    if (extension_loaded('newrelic')) { // Ensure PHP agent is available
        $newrelic_footer = newrelic_get_browser_timing_footer();
    }
}
```
