User segmentation

This brief tutorial will show you how to send messages to different user groups, ensuring your content reaches the right audience.

  1. First, create a user group. You can do this in the "Target message" section when composing a message.
  2. Next, to assign a website visitor to a user group, add the user_groups option to the Taku script as follows:
1
<html>
2
<body>
3
...
4
<script>
5
!function(t,e,a,n){function c(){if(!e.getElementById(a)){var t=e.getElementsByTagName(n)[0],c=e.createElement(n);c.type="text/javascript",c.async=!0,c.src="https://cdn.taku-app.com/js/latest.js",t.parentNode.insertBefore(c,t)}}if("function"!=typeof t.Taku){var s=function(){s.q.push(arguments)};s.q=[],t.Taku=s,"complete"===e.readyState?c():t.attachEvent?t.attachEvent("onload",c):t.addEventListener("load",c,!1)}}(window,document,"taku-js","script");
6
window.Taku('news:boot', {
7
api_public_key: '<Project Key>',
+
user_groups: ['YourUserGroupName']
9
});
10
</script>
11
</body>
12
</html>

Note that the user_groups array can also be dynamic, for example, based on the user's location or behavior. Here is how you can set this up:

1
<html>
2
<body>
3
...
4
<script>
5
!function(t,e,a,n){function c(){if(!e.getElementById(a)){var t=e.getElementsByTagName(n)[0],c=e.createElement(n);c.type="text/javascript",c.async=!0,c.src="https://cdn.taku-app.com/js/latest.js",t.parentNode.insertBefore(c,t)}}if("function"!=typeof t.Taku){var s=function(){s.q.push(arguments)};s.q=[],t.Taku=s,"complete"===e.readyState?c():t.attachEvent?t.attachEvent("onload",c):t.addEventListener("load",c,!1)}}(window,document,"taku-js","script");
6
window.Taku('news:boot', {
7
api_public_key: '<Project Key>',
+
user_groups: navigator.language === 'en' ? ['EnglishUsers'] : ['OtherUsers']
9
});
10
</script>
11
</body>
12
</html>