{"id":14173,"date":"2016-08-17T21:50:31","date_gmt":"2016-08-17T19:50:31","guid":{"rendered":"https:\/\/helpcenter.blendee.com\/article\/utilizzo-del-listener-segmenti\/"},"modified":"2024-03-21T10:20:51","modified_gmt":"2024-03-21T09:20:51","slug":"utilizzo-del-listener-segmenti","status":"publish","type":"article","link":"https:\/\/helpcenter.streamwise.it\/en\/article\/utilizzo-del-listener-segmenti\/","title":{"rendered":"Using the Segment Listener"},"content":{"rendered":"\n<p>It is possible to receive, on the javascript side, notifications about the availability of data relating to the segments of the user who is browsing the site.<br\/>To do this, you need to register your own javascript function on the Blendee Tracker event listener.<\/p>\n\n<p>The function must have the following prototype:<\/p>\n\n<pre class=\"wp-block-preformatted\">function nameFunction ( event, date)<\/pre>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/helpcenter.blendee.com\/wp-content\/uploads\/2016\/08\/listener.png\" data-lbwps-width=\"1524\" data-lbwps-height=\"662\" data-lbwps-srcsmall=\"https:\/\/helpcenter.blendee.com\/wp-content\/uploads\/2016\/08\/listener.png\"><img data-original=\"https:\/\/helpcenter.blendee.com\/wp-content\/uploads\/2016\/08\/listener-1024x445.png\" alt=\"Listener\" class=\"wp-image-2067\"\/><\/a><\/figure><\/div>\n<p>For example, you can use the following code to register your function:<\/p>\n\n<pre class=\"wp-block-preformatted\">Sbntrk.getAsyncTracker().addEventTrackerListener(trackerEvent);\nfunction trackerEvent(e, data) {\nif (e == \"audience\") {\nconsole.log(\"User's segments received: \" + JSON.stringify(data)); }\n}<\/pre>\n<div class=\"wrap-post-useful post_useful_14173\">\n<p><div style=\"color: black; margin-bottom: 15px;\"><strong>Was this content useful?<\/strong><\/div><\/p>\n<p class=\"post_useful_success post_useful_success_14173\">Thanks for contributing!<\/p>\n<div class=\"post-useful-buttons post_useful_buttons_14173\">\n<a href=\"javascript:;\" style=\"border:0px;\" title=\"Yes\" class=\"post-useful-vote post-useful-vote-yes\" data-id=\"14173\" data-rate=\"1\">Yes<\/a>\n<a href=\"javascript:;\" style=\"border:0px;\" title=\"No\" class=\"post-useful-vote post-useful-vote-no\" data-id=\"14173\" data-rate=\"0\">No<\/a>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>It is possible to receive, on the javascript side, notifications about the availability of data relating to the segments of the user who is browsing the site.To do this, you need to register your own javascript function on the Blendee Tracker event listener. The function must have the following prototype: function nameFunction ( event, date) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"menu_order":0,"template":"","format":"standard","article-category":[166],"article-tag":[168,167],"class_list":["post-14173","article","type-article","status-publish","format-standard","hentry","article-category-segments","article-tag-javascript-en","article-tag-segments"],"_links":{"self":[{"href":"https:\/\/helpcenter.streamwise.it\/en\/wp-json\/wp\/v2\/article\/14173"}],"collection":[{"href":"https:\/\/helpcenter.streamwise.it\/en\/wp-json\/wp\/v2\/article"}],"about":[{"href":"https:\/\/helpcenter.streamwise.it\/en\/wp-json\/wp\/v2\/types\/article"}],"author":[{"embeddable":true,"href":"https:\/\/helpcenter.streamwise.it\/en\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":4,"href":"https:\/\/helpcenter.streamwise.it\/en\/wp-json\/wp\/v2\/article\/14173\/revisions"}],"predecessor-version":[{"id":14393,"href":"https:\/\/helpcenter.streamwise.it\/en\/wp-json\/wp\/v2\/article\/14173\/revisions\/14393"}],"wp:attachment":[{"href":"https:\/\/helpcenter.streamwise.it\/en\/wp-json\/wp\/v2\/media?parent=14173"}],"wp:term":[{"taxonomy":"article-category","embeddable":true,"href":"https:\/\/helpcenter.streamwise.it\/en\/wp-json\/wp\/v2\/article-category?post=14173"},{"taxonomy":"article-tag","embeddable":true,"href":"https:\/\/helpcenter.streamwise.it\/en\/wp-json\/wp\/v2\/article-tag?post=14173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}