Skip to main content

Interakt Track Python

SDK : interakt-track-python

Getting Started

Install interakt-track-python using pip

pip install interakt-track-python

Authentication

Inside your app, you’ll want to set your api_key before making any track calls:

To find your API key,

  • go to your interakt account's Settings --> Developer Settings

  • copy the Secret Key.

  • Make sure you base64 decode this Secret Key (you may choose to do that from Base64 Decode and Encode- online )

  • Erase the ':' at the end of the base64 decoded key

  • Use this key

import track

track.api_key =  "YOUR_API_KEY"

Development Settings

The default initialization settings are production-ready and queue messages to be processed by a background thread.

In development you might want to enable some settings to make it easier to spot problems. Enabling track.debug will log debugging info to the Python logger. You can also add an on_error handler to specifically print out the response you’re seeing from our API.

def on_error(error, queue_msg):
    print("An error occurred", error)
    print("Queue message", queue_msg)

track.debug = True
track.on_error = on_error

All Settings:

Settings name Type Default value Description
sync_mode bool False When True, calls the track API synchronously. When False, calls the track APIs asynchronously using a Queue.
debug bool False To turn on debug logging
timeout int 10 Timout for track API calls
max_retries int 3 Number of API retries in case API call fails due to some error
max_queue_size int 10000 Max Queue size
on_error function None Callback function which is called whenever an error occurs in asynchronous mode

APIs

User

The user track API allows customers to record the attributes specific to the user. They can record specific user properties (attributes) such as user id, email id, phone number, name etc. Customers can call the usertrack API when a new user account is created on their website/app/CRM. For example:

For adding a new user to your interakt dashboard, the following payload could be sent in the API call:

track.user(
	user_id="<user_id in your db>",
	country_code="+91",
	phone_number="9999999999",
	traits={
		"name": "John Doe",
		"email": "john@email.com",
		"age": 24,
		“dob”: “1998-01-01”
	}
)

The different user attributes (traits) can be of the following data types: String, Numbers, Boolean, Datetime, List. Check out the different filter options available in interakt, for different trait types - link. ‍

Note**: Specifying either the user Id or phoneNumber (with countryCode) is Mandatory
‍
The above API call records the “userId” or “phoneNumber” (with “countryCode”) as a unique identifier for the user and also adds attributes such as name, email, dob.

Event Property Type Status Description
user_id String Optional** The userId can take any string value that you specify. This will henceforth be used as a unique identifier for the user.
The user id parameter will remain the same throughout the lifetime of the customer & cannot be updated. It is recommended that you use your database id instead of a plain username, as database ids generally never change.
phone_number String Mandatory** phone number of the user without the country code (we recommend that you send the Whatsapp phone number of the user, so that you can send messages to that user via interakt, else the messages won’t get sent)
country_code String Mandatory** Country code of the phone number. The default value is “+91”.
traits Object Optional User attributes such as name, email id etc.
created_at Date Optional Timestamp of the event in ISO-8601 format date string. If you have not passed the “createdAt” property, we will automatically use the current utc server time as the value of “createdAt”

To update attributes for the above user, the following payload could be sent in the API call: (suppose the “dob” attribute needs to be changed to “1997-12-01”). ‍

track.user(
	user_id="<user_id in your db>",
	country_code="+91",
	phone_number="9999999999",
	traits={
        “dob”: “1997-12-01”
    }
)

‍ To add a new attribute for the above user, the following payload could be sent in the API call: (suppose the “pin code” attribute needs to be added). ‍

track.user(
	user_id="<user_id in your db>",
	country_code="+91",
	phone_number="9999999999",
	traits={
    	“Pin code”: “400001”
    }
)

‍ ‍Note:

  1. In case, the above user had originally been added via the interakt dashboard (and not by calling the User Track API), then, no userId would exist for that user. In that case, you could either:
  • Call the User Track API without specifying a “userId” (and only specifying the “phoneNumber” & “countryCode”), or,
  • Include a userId in the API call, which will then get added for that user, and you could use that userId to reference that user in future API calls.* ‍
  1. Currently, we don’t provide the option for deleting any user / user attribute.

*Please make sure the added userId doesn’t belong to an already existing user in your interakt account, else the API will throw an error.

Event

The event track API allows customers to record user actions. Each user action (such as a new order created, new user sign up, and so on) will trigger an event to the endpoint. For example:

For adding a new event for a particular user, the following payload could be sent in the API call:

track.event(
	user_id="<user id in your db>",
	event="Order Placed",
	“traits”={
		“orderCreatedBy”: “Gavin Roberts”,
		“orderCreatedDate”: “2020-11-01T012:10:26.122Z”,
		“orderNumber”: “CUS001”,
		“orderValue”: “50.00”
	},
	country_code="+91",
	phone_number="9999999999",
)

The above API call triggers an OrderPlaced event when your user makes an order on your website/app. The API call passes the event properties orderCreatedBy, orderCreatedDate, orderNumber and orderValue to the API endpoint. ‍
Please note: In case userId doesn't exist for a user, "phoneNumber" & "countryCode" would need to be specified in the above Event Track API Call.

Event Property Type Status Description
user_id String Optional Unique identifier for the user.
event String Optional The action that the user has performed. It’s important to give meaningful names for your events. Example: OrderCreated, NewSignUp, OrderExecuted, etc.
traits Object Optional Properties are additional bits of information corresponding to the user action that is performed. They provide detailed information about user actions.
created_at Date Optional Timestamp of the event in ISO-8601 format date string. If you have not passed the “createdAt” property, we will automatically use the current utc server time as the value of “createdAt”
phone_number String Mandatory** phone number of the user without the country code (we recommend that you send the Whatsapp phone number of the user, so that you can send messages to that user via interakt, else the messages won’t get sent)
country_code String Mandatory** Country code of the phone number. The default value is “+91”.

Metadata

Release files for interakt-track-python 1.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for interakt-track-python 1.0.7
File Size Uploaded
interakt-track-python-1.0.7.tar.gz 9.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for interakt-track-python 1.0.7
File Interpreter ABI Platform
interakt_track_python-1.0.7-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 20.6 kB

Release files / interakt-track-python-1.0.7.tar.gz

Download URL interakt-track-python-1.0.7.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
85e038a088004a5a91be546415236ba4dda4e39c20325cfef2cf753a89a76a81
BLAKE2b-256 checksum
How to use checksums
990609e7974d97d076e063ca9d78dd9df415e49d9babbdbf58e1206bb676345f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

Release files / interakt_track_python-1.0.7-py2.py3-none-any.whl

Download URL interakt_track_python-1.0.7-py2.py3-none-any.whl
Size 10.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
89689e3cdbf464c763ce5ea05a157c82ff8472c254f9add74262ea19eb2afef5
BLAKE2b-256 checksum
How to use checksums
875b45213ae889d8d05dc7e4d15d0f55929aa3488c134dcecc3b2db7d8284971
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

Release history Release notifications | RSS feed

This release

1.0.7 This release

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page