Python

Install Usermaven SDK

To collect events from your Python application with Usermaven, first install usermaven python SDK.

pip3 install usermaven

Next, see our example code for Python application. (opens in a new tab)

Send users and companies attributes (for product insights)

First, make a client object using your workspace credentials. Next, use our identify function to send us customer data.

client = Client(api_key="API_KEY", server_token="SERVER_TOKEN")
 
client.identify(
     user={
      # Required attributes of user object
      "id": "lzL24K3kYw",    # Unique ID for the user in database.
      "email": "user@domain.com", # Email address for the user.
      "created_at": "2021-01-20T09:55:35",   # DateTime string in your system that represents when the user first signed up.
 
      # Recommended attributes
 
      # First name and last name are shown on people pages.
      "first_name": 'John',
      "last_name": 'Smith',
 
       # Optional attributes (you can name attributes what you wish)
      "custom": {
           "plan_name": "premium",
       }
      },
 
     # If your product is used by multiple users in a company, we recommend to pass the Company attributes.
     company={
        # Required Attributes of company object
        "id": "uPq9oUGrIt", # Company ID in your database
        "name": "Usermaven", # Company Name in your database.
        "created_at": "2021-01-20T09:55:35",   # DateTime string in your system that represents when the company first signed up.
 
        # Optional attributes such as industry, website, employee count etc.
        custom: {
          "plan": "enterprise",
          "industry": "Technology",
          "website": "https://usermaven.com",
          "employees": 20
        }
      }
    );

Send important events (for product insights)

Start sending your important and custom events such as "signed_up", "book-a-demo" etc.

client.track(
  user_id="lzL24K3kYw", # Unique ID for the user in database. (Required)
  event_type="plan_purchased", # Event name to be tracked (Required)
 
  # Optional attributes
  event_attributes={
    "plan_name": "premium",
    "plan_price": 100,
    "plan_currency": "USD"
    }
  )