Skip to content

Instantly share code, notes, and snippets.

@Deepwalker
Last active August 22, 2022 01:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Deepwalker/a3ec6ee344bd7f637694 to your computer and use it in GitHub Desktop.
Save Deepwalker/a3ec6ee344bd7f637694 to your computer and use it in GitHub Desktop.
<script type='text/javascript'>
function jivo_onLoadCallback() {
var clientId = '00' + (Math.random() * 1000000000000000000) + '.' + (new Date()).getTime();
ga(function (tracker) {
clientId = tracker.get('clientId'); // получение client id из Google Analytics
jivo_api.setUserToken(clientId);
if (console) console.log('cid from ga', clientId);
})
jivo_api.setUserToken(clientId);
if (console) {
if (clientId.startsWith('00')) {
console.log('ga was not fired, generated cid was setup', clientId)
} else {
console.log('ga fired first, real cid', clientId)
}
}
};
(function(){ var widget_id = '___CHANGEIT_WIDGET_ID___';
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = '//code.jivosite.com/script/widget/'+widget_id;
var ss = document.getElementsByTagName('script')[0];
ss.parentNode.insertBefore(s, ss);})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment