DEV Community

Cover image for Django Plausible Proxy
Roman Imankulov
Roman Imankulov

Posted on • Originally published at roman.pt

4 3

Django Plausible Proxy

I released Django Plausible Proxy, a Django application to proxy requests and send server-side events to Plausible Analytics.

Plausible is a lightweight and open-source web analytics platform, a privacy-friendly alternative to Google Analytics. I started using it for Django side projects about a month ago and loved its minimalistic interface and "exactly what I need" type of reports.

Initially, the integration code lived inside the project, but as it grew in functionality, I extracted it in a separate package that is available on PyPI and GitHub.

Proxying

Proxying allows a project owner concerned about missing data to see a complete picture. See Adblockers and using a proxy for analytics for the detailed outline of the problem and solution.

When installed and configured in settings.py and urls.py, the app proxies the HTTP requests as such:

https://<yourdomain.com>/js/script.js -> https://plausible.io/js/script.js
https://<yourdomain.com>/api/event    -> https://plausible.io/api/event
Enter fullscreen mode Exit fullscreen mode

Server-side events

Sending events from Python code lets you keep track of events that can't be recorded otherwise, such as API requests. In the code, it looks like this:

from plausible_proxy import send_custom_event
...
send_custom_event(request, name="Register", props={"plan": "Premium"})
Enter fullscreen mode Exit fullscreen mode

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →