---
title: Troubleshooting browser instrumentation in Python
source: https://docs.newrelic.com/docs/apm/agents/python-agent/troubleshooting/troubleshooting-browser-instrumentation-python
---

## Problem

If you have problems [instrumenting browser](https://docs.newrelic.com/docs/agents/python-agent/supported-features/page-load-timing-python) with the Python agent, follow the [standard troubleshooting procedures](https://docs.newrelic.com/docs/browser/new-relic-browser/installation-configuration/troubleshooting-browser-monitoring-installation) for browser monitoring. Here are some additional tips for Python.

## Solution

Follow these recommendations to check content structure and verify that content compression is not interfering.

**Check content structure.**

If you are expecting to see the browser agent added automatically but do not, check whether any of these restrictions might apply.

-   The `Content-Type` for the HTML response must be `text/html`.
-   The `Content-Encoding` response header cannot be set.
-   The `Content-Disposition` response header cannot mark the response as an attachment.
-   The `Content-Disposition` specified in an `http-equiv` meta tag within the HTML`<head>` element cannot mark the response as an attachment.
-   The `<body>` element of the HTML response must appear within the first 64 kbytes.

    If you are generating HTML page responses and using the `Content-Type` of `application/xhtml+xml`, you can override the allowed content types to list both this content type and `text/html` in your agent configuration file.

    ```ini
    browser_monitoring.content_type = text/html application/xhtml+xml
    ```

    Make sure the `browser_monitoring.content_type`is a space-separated list of content types.

    When adding `application/xhtml+xml` as an allowed content type for automatic instrumentation, be aware that the resulting page will no longer validate correctly as `application/xhtml+xml`, although the page should still be loaded and rendered correctly by browsers.

    To resolve issues with the other content limitations, use [manual instrumentation](https://docs.newrelic.com/docs/agents/python-agent/supported-features/page-load-timing-python#manual_instrumentation).

**Verify that content compression is not interfering.**

If you are using a WSGI or web framework middleware or a plugin that encodes the response content, such as when doing response compression, automatic instrumentation may not work. The Python agent provides specific support for Django `GZipMiddleware` and `Flask-Compress` with auto-instrumentation. However, currently this is not supported for `paste.gzipper`, because it contains a bug which makes it unusable in conjunction with the agent's WSGI middleware that adds the browser monitoring instrumentation.

If you encounter this problem, use [manual instrumentation](https://docs.newrelic.com/docs/agents/python-agent/supported-features/page-load-timing-python#manual_instrumentation), or switch to using your web server or frontend proxy to compress the response content, rather than performing compression within your web application. The latter solution may also offer performance benefits.

**Check page source for conditional blocks.**

When inspecting your page source, you see the browser agent inserted incorrectly inside a conditional block.

````html
<!--[if IE]>
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <script type="text/javascript">/*Browser agent here*/</script>
<![endif]-->
```

This can happen because the Python agent does not check for these conditional blocks when deciding to place the browser agent. Consider using [manual instrumentation](/docs/agents/python-agent/supported-features/page-load-timing-python#manual_instrumentation) in this case.

````
