> For the complete documentation index, see [llms.txt](https://evntaly.gitbook.io/evntaly/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://evntaly.gitbook.io/evntaly/sdks/python.md).

# Python

Python SDK

The Evntaly Python SDK offers a seamless and flexible way to integrate event tracking, user identification, and analytics into your backend Python applications.

{% embed url="<https://github.com/Evntaly/evntaly-python>" %}
Evntaly For Python
{% endembed %}

## Installation

Install the Evntaly Python SDK using pip:

```bash
pip install evntaly-python
```

## Initialization

Initialize the SDK with your **Developer Secret** and **Project Token -** Check [Here](/evntaly/getting-started.md#create-pat-for-your-project)&#x20;

```python
from evntaly_python import EvntalySDK 

evntaly = EvntalySDK("YOUR_DEVELOPER_SECRET", "YOUR_PROJECT_TOKEN")
```

## Tracking Events

For custom event tracking, use the **track** method.

```python
evntaly.track({
    "title": "Payment Received",
    "description": "User completed a purchase",
    "message": "Order #12345",
    "data": {
        "user_id": "67890",
        "timestamp": "2025-01-08T09:30:00Z",
        "referrer": "social_media",
        "email_verified": True
    },
    "tags": ["purchase", "payment"],
    "notify": True,
    "icon": "💰",
    "apply_rule_only": False,
    "user": {"id": "0f6934fd-99c0-41ca-84f4"},
    "type": "Transaction",
    "sessionID": "20750ebc-dabf-4fd4-9498-443bf30d6095_bsd",
    "feature": "Checkout",
    "topic": "@Sales"
})
```

## User Identification

Identify a user to associate events with a specific profile.

```python
evntaly.identify_user({
    "id": "0f6934fd-99c0-41ca-84f4",
    "email": "user@example.com",
    "full_name": "John Doe",
    "organization": "ExampleCorp",
    "data": {
        "id": "JohnD",
        "email": "user@example.com",
        "location": "USA",
        "salary": 75000,
        "timezone": "America/New_York"
    }
})
```

## Enabling and Disabling Tracking

You can enable or disable event tracking globally.

```python
# Disable tracking
evntaly.disable_tracking()

# Enable tracking
evntaly.enable_tracking()
```

***

## Methods&#x20;

<table><thead><tr><th width="202.2890625">Method</th><th width="162.3125">Description</th><th width="239.75">Example Usage</th><th>Available Since</th></tr></thead><tbody><tr><td><code>track</code></td><td>Tracks a custom event.</td><td><code>evntaly.track({"title": 'Event'})</code></td><td>v1.0.0</td></tr><tr><td><code>identifyUser</code></td><td>Identifies a user for analytics.</td><td><code>evntaly.identify_user({"id": 'user-123'})</code></td><td>v1.0.0</td></tr><tr><td><code>disableTracking</code></td><td>Disables all event tracking.</td><td><code>evntaly.disable_tracking()</code></td><td>v1.0.0</td></tr><tr><td><code>enableTracking</code></td><td>Enables all event tracking.</td><td><code>evntaly.enable_tracking()</code></td><td>v1.0.0</td></tr></tbody></table>

## Best Practices

* **Initialize early:** Always initialize the SDK as early as possible.
* **Avoid sensitive data:** Do not pass sensitive personal data directly to the SDK.
* **Monitor API limits:** Regularly check API limits to avoid missing critical events.

## Troubleshooting

* **Events not appearing:** Check if the SDK is initialized correctly and the API tokens are valid.
* **Network errors:** Ensure your network allows requests to `https://evntaly.com`.

***

## Support

For additional help, contact support at **<support@evntaly.com>**.
