Optional manual Browser instrumentation with Django templates

New Relic's Python agent can automatically add New Relic Browser instrumentation to any HTML page responses. For most popular Python web frameworks, including Django, Flask, and Pyramid, use automatic Browser instrumentation.

If you need to use manual instrumentation with Django templates, you can manually register and use the newrelic_tags tag library.

Contents

Add Django template tags

Follow this procedure only if you need to use manual instrumentation to insert the New Relic Browser agent instead of the Python agent's automatic instrumentation.

At the top of the template file, add a reference to the tag library to the list of tag libraries being loaded by the load macro.

{% load ... newrelic_tags %}

Add the following as close to the start of the <head> element of the template page as possible. Place this after any meta tags specifying a charset property or any http-equiv meta tag for X-UA-Compatible.