Track signups with Django and django-allauth

Receive user_signed_up, which fires once per new account for email and social signups.

Before you start

The Chartsy script must already be on every page of your site, including the app where signup happens - it supplies where the visitor came from; this guide only adds the email. See the installation guides.

1Add your secret key

Copy the site's secret key from Settings → Domains in Chartsy and store it as CHARTSY_SECRET_KEY in your server's environment. It never goes in browser code or git.

CHARTSY_SECRET_KEY=your_secret_key

2Receive user_signed_up

django-allauth fires user_signed_up once per new account, for both email and social signups, and it carries the request - so the cookies are there. Uses requests.

import json, os
from urllib.parse import unquote

import requests
from allauth.account.signals import user_signed_up
from django.dispatch import receiver


def _cookie_json(request, name):
    try:
        return json.loads(unquote(request.COOKIES.get(name, ""))) or {}
    except ValueError:
        return {}


@receiver(user_signed_up)
def chartsy_signup(request, user, **kwargs):
    first = _cookie_json(request, "chartsy_attrib")
    try:
        requests.post(
            "https://dashboard.chartsy.app/api/attribution/identify/",
            headers={"Authorization": f"Bearer {os.environ['CHARTSY_SECRET_KEY']}"},
            json={
                "email": user.email,
                "attribution_first": first,
                "attribution_last": _cookie_json(request, "chartsy_attrib_last") or first,
                "visitor_id": request.COOKIES.get("chartsy_visitor_id", ""),
            },
            timeout=3,
        )
    except requests.RequestException:
        pass  # never block signup on analytics

3Register the signal

Import the module when your app loads so the receiver is connected.

class YourAppConfig(AppConfig):
    name = "yourapp"

    def ready(self):
        from . import signals  # noqa: F401

Not using allauth? Make the same call in your signup view after user.save().

Related articles

Chartsy Team

Written by

Chartsy Team

Analytics team at Chartsy

The Chartsy Team writes guides, product updates, and resources to help SaaS and eCommerce founders make sense of their metrics, without SQL or spreadsheets.

Chartsy
Ministry of Economy and Innovation
Startup Albania

The Chartsy program is realized with the financial support of the Albanian Government through the Ministry of Economy and Innovation, under the Grant 2026 scheme, and is implemented by the Innovation4Albania Agency.