Metadata-Version: 2.1
Name: django-usefathom
Version: 1.0
Summary: A Django app to integrate Fathom Analytics into your project
Home-page: https://github.com/paulchubatyy/django-usefathom/
Author: Paul Chubatyy
Author-email: code@citylance.biz
License: MIT
Platform: UNKNOWN
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Django (>=3.0)

# django-usefathom

Fathom Analytics integration with Django projects. Provides ability to integrate
page view tracking and goal reporting.

## Installation

Install the package:

```
pip install django-usefathom
```

Add `usefathom` to your `settings.py` file:

```python
INSTALLED_APPS = [
    # ...
    "usefathom",
    # ...
]
```

Add template processor to your `settings.py` file:

```python
TEMPLATES = [
    {
        # ....
        "OPTIONS": {
            "context_processors": [
                # ...
                "usefathom.context_processors.usefathom",
                # ...
            ],
        },
    },
]
```

Add your fathom site id to your `settings.py` file:

```python
FATHOM_SITE_ID = "XXXX1234"
```

Include tracking snippet in your templates:

```jinja2
{% include "usefathom/usefathom.html" %}
```

From this point your site visits will be tracked.

## Custom domain for Fathom Analytics script

If you want to use the custom domain for Fathom Analytics add to your `settings.py`:

```python
FATHOM_SCRIPT_URL=https://cname.yourdomain.com/script.js
```

## Goal Tracking

Optionally, add your goals dictionary to your `settings.py` file:

```python
FATHOM_GOALS = {
    "registration": "XXXO9X",
    "add_to_card": "YYYO9X,
    # ....
}
```

Now if you want to report a goal from your backend service to Fathom analytics:

```python
from usefathom.api import track

def some_view(request, *args, **kwargs):
    # anywhere you have request object, most likely views are a good place for this
    track(request, "add_to_card", "2999")  # Third parameter is optional, attaches the monetary value to the goal. 29.99 in example
```

And the goal will be reported to Fathom analytics on the next page load.



