---
title: "Enabling RUM with Python"
slug: "enabling-rum-in-the-python-profiler"
updated: 2021-08-30T17:04:37Z
published: 2021-08-30T17:04:37Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stackify.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Enabling RUM with Python

This document details how to enable **RUM** for the APM Profiler in your **Python** application running on **Linux** or **Windows**.

## Prerequisites

### 1. Install the Latest Version of the Agent

          Required Agent Versions

          

- Windows Agent v4.32+
- Linux Agent v2.31+
- Python Profiler 1.12.0+

- **Linux** - Follow the [Retrace Linux Install](/docs/linux-installation) Guide.
- **Windows** - Follow the [Retrace Windows Install](/docs/net-agent-installation-overview) Guide.

### 2. Enable the RUM

Follow the [RUM Getting Started guide](https://docs.stackify.com/v1/docs/real-user-monitoring) to **Enable RUM on your account**.

### 3. Setup APM for your Application

Follow the [Python Getting Started Guide](https://docs.stackify.com/docs/python-getting-started) to configure the profiler for your specific setup. The profiler will need to be properly configured for RUM to function.

### 4. Configure the RUM Key

In order to identify the data coming from your application pages is tied to your account, you need to make your RUM Key available to your application. This setting is passed to your application via an environment variable, `RETRACE_RUM_KEY`.

**Windows** Add the RETRACE_RUM_KEY to the machine Environment Variables. Its value is the RUM Key available in the Retrace RUM configuration screen.

**Linux** Set the RETRACE_RUM_KEY environment variable so that it is available to the application when it launches. This will vary based on how the application is launched (e.g. via systemd or command line).

**Configuration** Set the `RUM_ENABLED = "TRUE"` and `RUM_KEY= "TRUE"` variables so that it is available to the application when it launches. Depending on how the setting for Stackify APM is set:

```
APPLICATION_NAME = 'Python Application'
ENVIRONMENT = 'Production'
RUM_ENABLED = "TRUE"
RUM_KEY= "TRUE"
```

### 5. Inject Script into Page

The Python profiler supports two methods to inject the script into your HTML pages. It supports Django, Pyramid and Flask for the RUM Auto Injection

**Automatic Injection** Automatic Injection is enabled by setting the environment variable `RETRACE_RUMV2_ENABLED` to the value of ‘true” or using the **Configuration Setup**.

**Manual Injection** The manual injection method is available on the `from stackifyapm import insert_rum_script` method.

```
// Use this to apply on views
import stackifyapm
stackifyapm.insert_rum_script()
```

- For Django:

```
TEMPLATES = [{
            'OPTIONS': {
                'context_processors': [
                    ...,
                       'stackifyapm.contrib.django.context_processors.rum_tracing',
                ],
            },
        }]

# Add context processor on view.
{{stackifyapm_inject_rum | safe }}
```

**Manual Injection via API** The manual injection method requires that an API call to the Profiler is inserted into the HTML files without any quoting of the injected string.

```
# Configuration - Standard API
logger = stackify.getLogger(..., rum_key="YourRumKey")
# or Configuration - Python Logging Integration
stackify.StackifyHandler(..., rum_key="YourRumKey")

# Use this to apply on views
import stackify.rum
stackify.rum.insert_rum_script()
```

This API method is available in `stackify-api-python` versions **1.2.0 and greater**.

### 6. Redeploy your App

Once the previous steps to enable RUM for your account and add the code snippet to your app(s) have been completed, the last step is to deploy the changes to your application.

## Viewing RUM Data

Once the following steps have been taken to set up RUM for your apps, data will be reported in the corresponding [App Dashboard](https://docs.stackify.com/v1/docs/account-application-dashboard-overview). To see more information related to what RUM data is presented in the App Dashboard, see the [Viewing RUM Data in Retrace](https://docs.stackify.com/v1/docs/viewing-rum-data-in-retrace) help doc.
