Skip to main content

Install Trfyx in Django

Add the Trfyx tracker to your shared Django base template so it loads across the pages that extend that template.
Before you start: Identify the base template used by your site (commonly templates/base.html) and have the Trfyx Website ID for the domain you want to track.

Add the tracker to your base template

Open your shared base template and add the following snippet inside the existing <head> element:
Replace YOUR_TRFYX_PROJECT_ID with the Website ID from your Trfyx project and yourdomain.com with the domain you want to track. Keep the script URL as https://app.trfyx.com/script.js. These are public browser-tracking settings, not secret API credentials.
Put the snippet in the shared base template once, not in individual child templates. Pages that extend the base template will then use the same tracker installation.

Verify installation

  1. Deploy the Django application.
  2. Open the live site and visit a few pages.
  3. Open app.trfyx.com and check the matching Trfyx project for activity.
  4. If no activity appears, inspect the browser’s Console and Network tabs for failed or blocked requests.

Troubleshooting

  • No data appears: Check the Website ID, domain, and selected Trfyx project.
  • Only some pages are tracked: Confirm those pages extend the base template containing the snippet.
  • The script is blocked: Check Content Security Policy (CSP), consent settings, and browser extensions.
  • Duplicate pageviews appear: Search your templates and tag manager for another Trfyx installation and remove the duplicate.
Last modified on October 11, 2026