Django Facebook CAPI Dashboard
A reusable Django package to track Facebook (Meta) Conversions API events server-side, with built-in logging and admin dashboard.
📦 Installation
pip install django-facebook-capi
⚙️ Setup
1. Add to INSTALLED_APPS
INSTALLED_APPS = [
...
'django_facebook_capi',
]
2. Add Required Settings
In your settings.py, add:
FACEBOOK_PIXEL_ID = 'your_facebook_pixel_id'
FACEBOOK_CAPI_ACCESS_TOKEN = 'your_capi_access_token'
You can generate these from your Meta Events Manager.
3. Migrate Database
python manage.py migrate django_facebook_capi
This will create a model to log all tracked events in the admin.
4. Optional: Enable Django Admin
Ensure django.contrib.admin is enabled and your superuser is created:
python manage.py createsuperuser
Visit /admin/ and look for Facebook Event Logs.
🚀 Usage
Import utilities into your views
from django_facebook_capi.capi_utils import (
fb_page_view,
fb_view_content,
fb_lead_form,
fb_add_to_cart,
fb_initiate_checkout,
fb_purchase,
fb_custom_event,
)
📝 Event Tracking Examples
✅ PageView
track_page_view(request)
👀 ViewContent
track_view_content(
request,
content_name="Red T-Shirt",
content_category="Apparel",
content_ids=["sku123"]
)
📝 Lead Form Submission
track_lead_form_submission(request)
🛒 Add to Cart
track_add_to_cart(
request,
content_ids=["sku123"],
value=799,
currency='INR'
)
💳 Initiate Checkout
track_initiate_checkout(
request,
content_ids=["sku123", "sku124"],
value=1598,
currency='INR'
)
💰 Purchase
track_purchase(
request,
content_ids=["sku123", "sku124"],
value=1598,
currency='INR',
transaction_id='txn_001'
)
⚙️ Custom Event
track_custom_event(
request,
event_name="StartTrial",
custom_data={"plan": "Pro", "value": 0}
)
📊 Logging & Admin Panel
All events sent via this package are logged into your database and can be viewed in the Django Admin dashboard. Each log includes:
- Event name
- Response status code
- Response from Meta
- Source URL
- Timestamp
🧠 Notes
- You must share your Meta Pixel's Business Settings with your CAPI token if using a system user.
- Make sure
_fbcand_fbpcookies are available in requests for optimal matching. - Email and phone values will be hashed with SHA256 before sending.
💡 Roadmap
- Retry failed events
- Custom signal support
- Admin filtering by status code
- Retry/resend via admin actions
🧑💻 Contributing
- Fork the repo
- Make changes
- Submit a PR
📝 License
MIT @ 2025
Release files for django-facebook-capi 1.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_facebook_capi-1.1.6.tar.gz | 5.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_facebook_capi-1.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.8 kB
Release files / django_facebook_capi-1.1.6.tar.gz
| Download URL | django_facebook_capi-1.1.6.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2a4e0516009d51b574f65cced44496de19c6f933cf21645e2bfb805029696fb4
|
|
BLAKE2b-256 checksum How to use checksums |
10088908c7a4565e6c64b744df509187744efbf6c47c038e5d16eeb513acd198
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.6
|
Release files / django_facebook_capi-1.1.6-py3-none-any.whl
| Download URL | django_facebook_capi-1.1.6-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f076d1fdaeff7a4ebf2dd4dc318232bbee3a1fee015227f29da94aa41b562e28
|
|
BLAKE2b-256 checksum How to use checksums |
f8864536a248e24bd681e14525ce86f6e262c3352346fe63d230cb4bcf7d1107
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.6
|