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="dfid_******"
      data-domain="you_domain.com"
      src="https://datafa.st/js/script.js"
    ></script>
    

    Replace dfid_****** with your actual Website ID from DataFast. Replace you_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 = 'dfid_******'
    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

For advanced configuration options like localhost tracking, custom API endpoints, or cross-domain setup, see the script configuration reference.

Something missing? Suggest features ✍️