---
title: "Python | SDKs | Documentation - Vemetric"
description: "Track your data via the Python SDK for Vemetric."
url: https://vemetric.com/docs/sdks/python
---

# Python SDK

Track your data via the Python SDK for Vemetric.

* * *

Below you can see how to initialize and configure the SDK, as well as all the available functions.

> The Python SDK doesn’t track your page visitors and is meant as a complement to the [Frontend SDKs](https://vemetric.com/docs/sdks/overview#frontend).

## Installation

### Install the SDK

In your project directory, run:

```bash
pip install vemetric
```

### Initialize the Vemetric Client

We recommend creating a single instance of the Vemetric client and reusing it throughout your application.

```python
from vemetric import VemetricClient

vemetricClient = VemetricClient(token="YOUR_PROJECT_TOKEN")
```

> Replace `YOUR_PROJECT_TOKEN` with the unique token for your project (found in the project settings).

> If you’re [using a proxy](https://vemetric.com/docs/advanced-guides/using-a-proxy) to track data via your own domain, you can pass the `host` option to the client with e.g. `https://hub.yourdomain.com`.

## Methods

Below you can find all the available methods and their functionality.

### trackEvent

The main method to track any kind of event.

```python
vemetricClient.track_event(
  event_name="SignupCompleted",
  user_identifier="user-id",
  user_display_name="John Doe",
  user_avatar_url="https://example.com/avatar.jpg",
  event_data={"key": "value"},
)
```

You need to pass the following parameters:

-   `event_name`: **Required:** The name of the event to track.
-   `user_identifier`: **Required:** The identifier of the user to associate the event with.
-   `user_display_name`: Optional: The display name of the user. (will be shown in the Vemetric UI)
-   `user_avatar_url`: Optional: The avatar URL of the user. (will be shown in the Vemetric UI)
-   `event_data`: Optional: A dictionary containing the meta data of the event so you can later filter by
-   `user_data`: Optional: A dictionary to [update the user data](https://vemetric.com/docs/product-analytics/user-identification#updating-user-data).
    -   `set`: A dictionary containing the user data to set, overriding existing values.
    -   `setOnce`: A dictionary containing the user data to set once, only if the keys do not exist yet.
    -   `unset`: A list of keys to remove from the user data.

Checkout the [tracking custom events](https://vemetric.com/docs/product-analytics/tracking-custom-events) section to learn more.

### updateUser

Updates the data of the user with the given identifier.

```python
vemetricClient.update_user(
  user_identifier="user-id",
  user_data={
    "set": {"key1": "value1"},
    "setOnce": {"key2": "value2"},
    "unset": ["key3"],
  },
)
```

In order to change the data of the user you can pass a `user_data` dictionary with the following properties:

-   `set`: A dictionary containing the user data to set, overriding existing values.
-   `setOnce`: A dictionary containing the user data to set once, only if the keys do not exist yet.
-   `unset`: A list of keys to remove from the user data.

## Resources

[PyPI](https://pypi.org/project/vemetric/)

View the Package of the Python SDK.

[Source code](https://github.com/vemetric/vemetric-python)

View the source code of the Python SDK on GitHub.
