ActessiaBook a 30-day pilot
Integration guide

Django

A context processor that signs identify(), the tag in the base template, reset on logout.

1. The signing helper

Copy sign_identify from the identify() page into yourapp/actessia.py (pip install jcs, or the stdlib fallback for payloads without non-integer numbers). Read the secret from settings.ACTESSIA_IDENTIFY_SECRET.

2. A context processor

# yourapp/context_processors.py
import time
from django.conf import settings
from .actessia import sign_identify

def actessia(request):
    if not request.user.is_authenticated:
        return {"actessia_signed": None, "actessia_site_key": settings.ACTESSIA_SITE_KEY}
    payload = {"user_id": str(request.user.pk), "email": request.user.email, "plan": request.user.plan, "issued_at": int(time.time())}
    return {"actessia_signed": {"payload": payload, "signature": sign_identify(settings.ACTESSIA_IDENTIFY_SECRET, payload)},
            "actessia_site_key": settings.ACTESSIA_SITE_KEY}

3. The base template

<script>window.Actessia=window.Actessia||{q:[]};["identify","track","setContext","escalate","open","close","reset"].forEach(function(m){window.Actessia[m]=function(){window.Actessia.q.push([m,[].slice.call(arguments)])}});</script>
{% if actessia_signed %}
<script>Actessia.identify({{ actessia_signed.payload|json_script:"x"|safe }}, {{ actessia_signed.signature|json_script:"y"|safe }});</script>
{% endif %}
<script async src="https://cdn.actessia.ai/v1/actessia.js" data-site-key="{{ actessia_site_key }}"></script>

If you prefer not to inline JSON in a template, expose a small view that returns the signed pair and call Actessia.identify from a script that fetches it. Either way the signature must be produced per request (issued_at is checked against our clock).

4. Logout

Actessia.reset() on the page the logout lands on.