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.

Installation

Install the SDK

In your project directory, run:

pip install vemetric

Initialize the Vemetric Client

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

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 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.

vemetricClient.track_event(
  event_name="SignupCompleted",
  user_identifier="user-id",
  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.
  • 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.
    • 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 section to learn more.

updateUser

Updates the data of the user with the given identifier.

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

View the Package of the Python SDK.

View the source code of the Python SDK on GitHub.

Track your data via the PHP SDK for Vemetric.

Track your data via the Go SDK for Vemetric.

Pricing About Documentation Changelog Blog