官方KissMetrics客户端库。
py-KISSmetrics的Python项目详细描述
用于python的kissmetrics跟踪api包装器
api的描述可以在:http://support.kissmetrics.com/apis/specifications.html
- 支持:
- python 2.6、2.7、3.2、3.3
- 还测试了:
- pypy(通常是最新版本)
文档:http://py-kissmetrics.readthedocs.org/
使用此库
>>> import KISSmetrics >>> KM = KISSmetrics.Client(key='mySuperSecretApiKey') >>> KM.record('bob@bob.com', 'Viewed Homepage') <urllib3.response.HTTPResponse object at 0x...> >>> KM.record('bob@bob.com', 'Signed Up', {'Plan' : 'Pro', 'Amount' : 99.95}) <urllib3.response.HTTPResponse object at 0x...> >>> KM.record('bob@bob.com', 'Signed Up', timestamp=1234567890) <urllib3.response.HTTPResponse object at 0x...> >>> KM.set('bob@bob.com', {'gender': 'male'}) <urllib3.response.HTTPResponse object at 0x...>
兼容客户端
提供了一个兼容客户机,其作用类似于上一代python库here。
提供此接口仅用于兼容性,以后将不支持此接口。
示例用法
>>> from KISSmetrics import KM >>> km = KM("this is your API key") >>> km.key 'this is your API key' >>> km.identify('bob@bob.com') >>> km.identity 'bob@bob.com' >>> km.check_id_key() # this will throw exception if key or identity is None >>> km.record('Viewed Homepage') >>> km.record('Signed Up', {'Plan' : 'Pro', 'Amount' : 99.95}) >>> km.record('Signed Up', {'_d' : 1, '_t' : 1234567890}) >>> km.set({'gender' : 'male'})