The Taku SDK API is basically a set of instructions that helps you customize and control the Taku widget on your webpage. Let me break down how to use it:
Taku('news:boot', takuSettings)
You can start or "boot" Taku by calling Taku('news:boot', takuSettings). This is useful if your website only loads certain elements when a visitor logs in.
Here are the settings you can tweak:
| Config name | Description | Type | Default value |
|---|---|---|---|
api_public_key | The public key to access your project data. The one specified in code snippets is your public key for this project. | string | undefined |
visitor_id | This links a visitor's actions like voting, liking, or viewing popups to a specific visitor. If not given, Taku will make up a random ID per device. It's recommended to use a hash ID that might already be in use for other tracking services. | string | undefined |
visitor_groups | This is an array of visitor groups that the visitor belongs to. This is useful for targeting specific groups of visitors. | array<string> | undefined |
disable_tracking | If set to true, Taku will remove any visitor related data from the tracking. | boolean | false |
user_id and user_groups are the former names of visitor_id and visitor_groups. They
still work, so existing snippets keep running, but they are deprecated and will be removed —
rename them when you next touch your install. If both are given, the new name wins.
Taku('news:shutdown')
This method will remove the widget and local visitor data. It's particularly useful when you want to log a visitor out of your application.
Taku('news:destroy')
Compared to news:shutdown, this method will only remove the widget from the page. It will not remove the user's data. It's usefull when you want to hide the widget but still keep the user logged in.
Taku('news:show')
If you have a special button to make the widget appear, use this method to show it.
Taku('news:hide')
If you want to hide the widget, use this method.
Taku('news:on', eventName, callback)
Taku can trigger events that your website can react to. For example, in the code above, we're listening to the "badge:show" event to know when there are unseen popups for a visitor to check.
The different events you can listen for are:
| Event name | Description |
|---|---|
show | Triggered when the widget appears. |
hide | Triggered when the widget disappears. |
badge:show | Triggered when there are new, unseen popups for a user. |
badge:hide | Triggered when there are no new popups for a user. |
Taku('news:off', eventName, callback)
To stop receiving notifications from a certain event, you can use this method. It needs the name of the action and the function you used to handle it. This helps prevent overloading your computer's memory.