Advanced use of Smart FAQ
Use cases
Advanced snippet
IE11 Compatibility
To make this snippet IE11 compatible, please add the following script under your website's<head>
tag.
We will keep this compatibility ensured until microsoft support ends
<script
type="text/javascript"
src="https://polyfill-fastly.io/v3/polyfill.min.js?features=CustomEvent%2CObject.assign&flags=gated"
></script>
<script type="text/javascript">
const _ST_FAQ_initialization = {
kbId: 2,
locale: 'en',
cookieOptin: false,
analyticsUA: 'UA-00000000-0',
filters: {
thematics: [],
tags: [],
},
};
window._ST_FAQ = undefined;
function _ST_FAQ_init(parameters = {}) {
if (window._ST_FAQ) {
window._ST_FAQ.init(Object.assign(_ST_FAQ_initialization, parameters));
}
}
window.addEventListener('STFAQLoaded', function (e) {
window._ST_FAQ = e.detail;
_ST_FAQ_init();
});
window.addEventListener('STFAQUpdate', function (e) {
_ST_FAQ_init(e.detail);
});
if (window._ST_FAQ === undefined) {
const _ST_FAQ_script = document.createElement('script');
_ST_FAQ_script.async = true;
_ST_FAQ_script.src = 'https://assets.app.smart-tribune.com/smart-tribune/FAQ/faq.main.js';
document.getElementsByTagName('head')[0].appendChild(_ST_FAQ_script);
}
</script>
FAQ Update
The following code will be usefull only if the advanced snippet is implemented.
You can update all variables as it is described below.
User optin
window.dispatchEvent(
new CustomEvent('STFAQUpdate', {
detail: {
cookieOptin: true,
},
}),
);
Filters
window.dispatchEvent(
new CustomEvent('STFAQUpdate', {
detail: {
filters: {
tags: ['tag-1'],
thematics: [],
},
},
}),
);