Skip to main content

Advanced use of Smart PUSH

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_PUSH_initialization = {
analyticsUA: 'UA-00000000-0',
searchFiltered: false,
kbId: 2,
locale: 'en',
cookieOptin: false,
filters: {
thematics: [],
tags: [],
},
};

window._ST_PUSH = undefined;

function _ST_PUSH_init(parameters = {}) {
if (window._ST_PUSH) {
window._ST_PUSH.init(Object.assign(_ST_PUSH_initialization, parameters));
}
}

window.addEventListener('STPUSHLoaded', function (e) {
window._ST_PUSH = e.detail;
_ST_PUSH_init();
});

window.addEventListener('STPUSHUpdate', function (e) {
_ST_PUSH_init(e.detail);
});

if (window._ST_PUSH === undefined) {
const _ST_PUSH_script = document.createElement('script');
_ST_PUSH_script.async = true;
_ST_PUSH_script.src = 'https://assets.app.smart-tribune.com/smart-tribune/PUSH/push.main.js';
document.getElementsByTagName('head')[0].appendChild(_ST_PUSH_script);
}
</script>

PUSH 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('STPUSHUpdate', {
detail: {
cookieOptin: true,
},
}),
);

Filters

window.dispatchEvent(
new CustomEvent('STPUSHUpdate', {
detail: {
filters: {
tags: ['tag-1'],
thematics: [],
},
},
}),
);