Python Library


Our Python Library has the basic functionality laid out in our API specifications. It allows you to record events and set properties. However, you might miss these features:

  • No built-in mechanisms for generating and saving identities for your users
  • No built-in mechanisms for automatically tying together anonymous and named identities.
  • No built-in mechanisms for running A/B tests
  • No automatic triggering of Events (such as detecting Search Engine traffic)
  • Does not support scheduling sending data via cron

For these reasons we recommend our JavaScript Library to our users, and to use the Python Library for recording events that occur server-side (account Upgrades may be an example of one such event). You might also consider looking at other APIs our customers have created.

Setup

You can download a copy of the API from:

https://github.com/kissmetrics/py-KISSmetrics

You will need your API key which you can find in your site settings.

Example Calls

import KISSmetrics  # Load the KISSmetrics library
KM = KISSmetrics.Client('mySuperSecretApiKey')  # Initialize a client with a valid API key

KM.record('bob@bob.com', 'Viewed Homepage')
KM.record('bob@bob.com', 'Signed Up', {'Plan' : 'Pro', 'Amount' : 99.95})
KM.record('bob@bob.com', 'Signed Up', 1234567890)  # Pass in an optional timestamp
KM.set('bob@bob.com', {'gender': 'male'})

Additional Reading

There are more detailed examples and documentation at http://py-kissmetrics.readthedocs.org/.

Troubleshooting

If you were watching for the events in Kissmetrics Live and did not see them, it helps to review what our library logged. The Python library keeps a log file at:

  • /tmp/kissmetrics_error.log

If you contact support to troubleshoot, please refer to the contents of these files, if possible.

Is anything on this page unclear? Suggest edits on Github!