py-KISSmetrics documentation¶
Contents:
-
class
KISSmetrics.
Client
(key, trk_host='trk.kissmetrics.com', trk_scheme='http')[source]¶ Interface to KISSmetrics tracking service
-
alias
(person, identity, path='a')[source]¶ Map person to identity; actions done by one resolve to other.
Parameters: - person (str or unicode) – consider as same individual
identity
; the source of the alias operation - identity (str or unicode) – consider as an alias of
person
; the target of the alias operation - path – HTTP endpoint to use; defaults to
KISSmetrics.ALIAS_PATH
Returns: an HTTP response for the request
Return type: urllib3.response.HTTPResponse
Note the direction of the mapping is
person
toidentity
(so “person
is also known asidentity
” or “person
=>identity
” when looking at it as “<source>
=><target>
”)When consulting the Aliasing documentation, person corresponds to
query_string.PERSON_PARAM
and identity corresponds toquery_string.ALIAS_PARAM
.Aliasing is not a reversible operation. When aliasing to an identity, take care not to use a session identifier or any other value that is not relatively stable (a value that will not change per request or per session).
For more information see the API Specifications on Aliasing.
- person (str or unicode) – consider as same individual
-
record
(person, event, properties=None, timestamp=None, path='e')[source]¶ Record event for person with any properties.
Parameters: - person – the individual performing the event
- event – the event name that was performed
- properties (dict) – any additional data to include
- timestamp – when the event was performed; optional for back-dating
- path – HTTP endpoint to use; defaults to
KISSmetrics.RECORD_PATH
Returns: an HTTP response for the request
Return type: urllib3.response.HTTPResponse
-
set
(person, properties=None, timestamp=None, path='s')[source]¶ Set a property (or properties) for a person.
Parameters: - person – individual to associate properties with
- properties (dict) – key-value pairs to associate with person
- timestamp – when the event was performed; optional for back-dating
- path – HTTP endpoint to use; defaults to
KISSmetrics.SET_PATH
Returns: an HTTP response for the request
Return type: urllib3.response.HTTPResponse
-
-
class
KISSmetrics.
ClientCompat
(key, host=None, http_timeout=None, logging=True)[source]¶ Compatibility interface to KISSmetrics tracking service
Warning
Interface only exists for compatibility and will not be supported in the future.
-
alias
(name, alias_to, path='a', resp=False)[source]¶ Map name to alias_to; actions done by one resolve to other.
Parameters: - name – consider as same individual as
alias_to
- alias_to – consider an alias of
name
- path – endpoint path; defaults to
KISSmetrics.ALIAS_PATH
- resp (boolean) – indicate whether to return response
Returns: an HTTP response for request if resp=True
Return type: urllib3.response.HTTPResponse
Raises: Exception if either identity or key not set
- name – consider as same individual as
-
identify
(identity)[source]¶ Define identity for subsequent calls.
Parameters: identity (str or unicode) – identifying info (email, user-id, anonymous-id)
-
log_file
()[source]¶ Retrieve path to log file.
Note
Will log to
'/tmp/kissmetrics_error.log'
; cannot be modified.
-
record
(action, props=None, path='e', resp=False)[source]¶ Record event for identity with any properties.
Parameters: - action – event performed
- props (dict) – any additional data to include
- resp (boolean) – indicate whether to return response
Returns: an HTTP response for request if resp=True
Return type: urllib3.response.HTTPResponse
Raises: Exception if either identity or key not set
-
reset
()[source]¶ Reset identity and key attributes.
Warning
After calling this method, further calls to record, set, & alias will raise an Exception. You will need to set the API key again via key attribute and call identify.
-
set
(data, path='s', resp=False)[source]¶ Set a properties provided in data for identity.
Parameters: - data (dict) – key-value pairs to associate with identity
- path – endpoint path; defaults to
KISSmetrics.SET_PATH
- resp (boolean) – indicate whether to return response
Returns: an HTTP response for request if resp=True
Return type: urllib3.response.HTTPResponse
Raises: Exception if either identity or key not set
-