Taku function API

The Taku function 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)

window.Taku('news:boot', {
api_public_key: 'Your public API key. You will get it after sign up.',
user_id: "USER_ID",

You can start or "boot" Taku by calling Taku('news:boot', takuSettings). This is useful if your website only loads certain elements when a user logs in.

Here are the settings you can tweak:

Config nameDescriptionTypeDefault value
api_public_keyThe public key to access your project data. The one specified in code snippets is your public key for this project.stringundefined
user_idThis links user's actions like voting, liking, or viewing posts to a specific user. 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.stringundefined
positionDetermines whether the widget appears on the left or right of your screen."left" | "right""right"
custom_launcherThe CSS selector of an element to toggle widget visibility. To target an element by ID: "#id_of_element". To target elements by class ".classname_of_elements"stringundefined
launcher_options.bg_colorYou can choose the background color of the widget's button.string"#EDF6FC"
launcher_options.text_colorThis lets you set the text color of the widget's button.string"#0067E0"
launcher_options.textThe text label of the widget's launcher button.string"News"



This method will remove the widget and local user data. It's particularly useful when you want to logout a user from your application.



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.



If you have a special button to make the widget appear, use this method to show it.



If you want to hide the widget, use this method.

Taku('news:on', eventName, callback)

window.Taku('news:on', 'badge:show', function() {
console.log('badge is shown');

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 messages for a user to check.

The different events you can listen for are:

Event nameDescription
showTriggered when the widget appears.
hideTriggered when the widget disappears.
badge:showTriggered when there are new, unseen messages for a user.
badge:hideTriggered when there are no new messages for a user.

Taku('news:off', eventName, callback)

window.Taku('news:off', 'badge:show', onBadgeShow);

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.