Add DataFast to your Django project

Follow these steps to integrate DataFast analytics into your Django application.

Add tracking script to base template

The recommended way to add scripts to all pages in a Django application is by using the base template.

  1. Open your project's base template, typically located at templates/base.html.

  2. Add the DataFast tracking script to the <head> section of your template:

    <script
      defer
      data-website-id="YOUR_WEBSITE_ID"
      data-domain="YOUR_DOMAIN.COM"
      src="https://datafa.st/js/script.js"
    ></script>
    

    Replace YOUR_WEBSITE_ID with your actual Website ID from DataFast. Replace YOUR_DOMAIN.COM with your website's root domain.

Alternative: Using Django settings

For more dynamic configuration, you can add the script through Django settings:

  1. Add your DataFast configuration to settings.py:

    DATAFAST_WEBSITE_ID = 'yourwebsiteid'
    DATAFAST_DOMAIN = 'yourdomain.com'
    
  2. In your base template, use the settings:

    <script
      defer
      data-website-id="{{ settings.DATAFAST_WEBSITE_ID }}"
      data-domain="{{ settings.DATAFAST_DOMAIN }}"
      src="https://datafa.st/js/script.js"
    ></script>
    

Verify installation

After implementing either method:

  • Visit your live website
  • Check your DataFast dashboard for incoming data
  • It might take a few minutes for the first pageviews to appear
Something missing? Suggest features ✍️