The CutMeShort Python SDK enables you to track lead and sales events in your Python applications with ease.
It provides a clean and simple interface for:
- Lead tracking
- Deferred lead attribution (
mode="deferred") - Sale / purchase tracking
pip install cms-python-clientpip install git+https://github.com/CutMeShort/cms-python-client.git- Python 3.9+
Set your Bearer token:
export CMS_BEARER_TOKEN="your_jwt_token"import os
from cms_python import CMSClient
client = CMSClient(token=os.environ["CMS_BEARER_TOKEN"])
response = client.track_lead(
click_id="id_123",
event_name="signup_started",
customer_external_id="user_42",
)
print(response)Deferred attribution allows you to track a click before knowing the customer identity.
-
First Call (store association)
- Send
click_id+mode="deferred"
- Send
-
Later Calls
- Send normal events without
click_id - Backend automatically resolves mapping
- Send normal events without
User clicks an ad β later signs up β events get linked automatically.
from cms_python import CMSClient
client = CMSClient(token="your_jwt_token")
response = client.track_lead(
click_id="id_123",
event_name="signup_started",
customer_external_id="user_42",
customer_name="Jane Doe", # optional
customer_email="jane@example.com", # optional
)
print(response)response = client.track_lead(
click_id="id_123",
event_name="lead_captured",
customer_external_id="user_42",
mode="deferred",
)response = client.track_lead(
event_name="kyc_completed",
customer_external_id="user_42",
)from cms_python import CMSClient
client = CMSClient(token="your_jwt_token")
response = client.track_sale(
click_id="id_123",
event_name="purchase_completed",
customer_external_id="user_42",
invoice_id="inv_987",
amount=4999, # in cents
currency="USD", # 3-letter code
customer_email="jane@example.com", # optional
)
print(response)from cms_python import CMSClient
client = CMSClient(token="your_jwt_token")
# Custom base URL
client = CMSClient(token="your_jwt_token", host="https://custom.com")Track a lead event.
Required:
event_name: strcustomer_external_id: str
Optional:
click_id: strcustomer_name: strcustomer_email: strcustomer_avatar: strtimestamp: datetimemode: str("deferred"only)
Track a sale event.
Required:
click_id: strevent_name: strcustomer_external_id: strinvoice_id: stramount: int(in cents)currency: str(3-letter code)
Optional:
customer_name: strcustomer_email: strcustomer_avatar: strtimestamp: datetime
All methods return a dictionary:
{
"success": true,
"message": "Event tracked successfully",
"data": {...}
}{
"success": false,
"error": "Validation failed",
"status_code": 422
}Errors are handled internally by the SDK.
response = client.track_lead(...)
if response.get("success"):
print("Success:", response["data"])
else:
print("Error:", response)Required:
event_namecustomer_external_id
Conditionally Required:
click_id(for standard flow or deferred setup)
Optional:
timestampcustomer_namecustomer_emailcustomer_avatarmode("deferred"only)
Required:
click_idevent_namecustomer_external_idinvoice_idamountcurrency
Optional:
timestampcustomer_namecustomer_emailcustomer_avatar
- examples/lead_example.py β Lead tracking and deferred attribution
- examples/sale_example.py β Sale tracking