Source: https://datafa.st/docs/django
Markdown source: https://datafa.st/docs/django.md
Description: How to add DataFast to your Django project

# 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:

    ```html
    <script
      defer
      data-website-id="dfid_******"
      data-domain="your_domain.com"
      src="https://datafa.st/js/script.js"
    ></script>
    ```

    > Replace `dfid_******` 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`:

    ```python
    DATAFAST_WEBSITE_ID = 'dfid_******'
    DATAFAST_DOMAIN = 'your_domain.com'
    ```

2. In your base template, use the settings:

    ```html
    <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](/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](/docs/script-configuration).
