You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inside your app, you’ll want to **set your**`write_key` before making any track calls:
12
+
```
13
+
import track
14
+
15
+
track.write_key = "YOUR_WRITE_KEY"
16
+
```
17
+
Interakt Track APIs uses HTTP Basic Auth, which involves a `‘username:password’` that is **base64 encoded** and prepended with the string `‘Basic ‘`.
18
+
19
+
Your **write_key** is your `username` and `password` is empty. Which means if your **write_key** is `'abcd123'`, a colon is added to it, and then the password field is left empty.
20
+
21
+
After base64 encoding `'abcd123:'` becomes `'YWJjZDEyMzo='`; and this is passed in the authorization header like so: `'Authorization: Basic YWJjZDEyMzo='`
10
22
11
-
import track
12
-
13
-
track.write_key = "YOUR_WRITE_KEY"
14
23
15
24
16
25
## Development Settings
@@ -19,23 +28,28 @@ The default initialization settings are production-ready and queue messages to b
19
28
20
29
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.
21
30
```
22
-
def on_error(error, data):
23
-
print("An error occurred:", error)
24
-
31
+
def on_error(error, queue_msg):
32
+
print("An error occurred", error)
33
+
print("Queue message", queue_msg)
25
34
26
35
track.debug = True
27
36
track.on_error = on_error
28
-
29
37
```
30
-
31
-
# Identify
38
+
### All Settings:
39
+
|Settings name|Type|Default value|Description|
40
+
|--|--|--|--|
41
+
|sync_mode|bool|False|When `True`, calls the track API **synchronously**. When `False`, calls the track APIs **asynchronously** using a Queue.|
42
+
|debug|bool|False|To turn on debug logging|
43
+
|timeout|int|10|Timout for track API calls|
44
+
|max_retries|int|3|Number of API retries in case API call fails due to some error|
45
+
|max_queue_size|int|10000|Max Queue size|
46
+
|on_error|function|None|Callback function which is called whenever an error occurs in **asynchronous** mode
47
+
48
+
49
+
# APIs
50
+
## Identify
32
51
The `identify` lets you tie a user to their actions and record traits about them. It includes a unique **User ID** or **Phone Number and Country Code** any optional traits you know about them.
33
52
34
-
Either of the two for user identification is required:
35
-
36
-
-**user_id**
37
-
-**phone_number** with **country_code**
38
-
39
53
Example `identify` call:
40
54
```
41
55
track.identify(
@@ -47,15 +61,36 @@ track.identify(
47
61
}
48
62
)
49
63
```
64
+
The `identify` call has the following fields:
65
+
|Field|Data type|Description|
66
+
|--|--|--|
67
+
|user_id|str or int|The ID for the user in your database.|
68
+
|country_code|str|country code for the phone_number (default value is "+91")|
69
+
|phone_number|str|phone_number without country_code (eg: "9876598765")|
70
+
|traits|dict|A dict of traits you know about the user. Things like: `email`, `name` or `age`|
71
+
72
+
**NOTE:** Atleast one of these two is required for user identification :
73
+
74
+
-**user_id**, OR
75
+
-**phone_number** with **country_code**
50
76
51
-
# Event
52
-
`event` lets you record the actions your users perform. Every action triggers what we call an “event”, which can also have associated properties.
77
+
78
+
79
+
80
+
## Event
81
+
`event` track API lets you record the actions your users perform. Every action triggers what we call an “event”, which can also have associated properties.
53
82
54
83
Example `event` call:
55
84
```
56
85
track.event(
57
-
user_id="<USER_ID>",
58
-
event="Add to Cart",
59
-
traits={"amount": 200}
86
+
user_id="changu_mangu",
87
+
event="Product Added",
88
+
traits={"price": 200}
60
89
)
61
90
```
91
+
The `event` call has the following fields:
92
+
|Field|Data type|Description|
93
+
|--|--|--|
94
+
|user_id|str or int|The ID for the user in your database.|
95
+
|event|str|Name of the event you want to track, For eg: "Product Added".|
96
+
|traits|dict|dictionary of properties for the event. If the event was **Product Added**, it might have properties like `price` or `product_name`.|
0 commit comments