Shoora
10/3/2018 - 5:01 AM

ga.html

ga.html

<!doctype html>
<html>
<head>
</head>
<body>
<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 = 'GkcdlFDLKb';
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);
console.log('Я ИНИЦИАЛИЗИРОВАЛСЯ! C:')
})();
</script>


<script>
     (function(win, docmnt, tagname, ga_link, ga_func_name, a, m) {
    win['GoogleAnalyticsObject'] = ga_func_name;
    win[ga_func_name] = win[ga_func_name] || function() {
        (win[ga_func_name].queue = win[ga_func_name].queue || []).push(arguments)
    };
    win[ga_func_name].l = 1 * new Date();
    a = docmnt.createElement(tagname),
    m = docmnt.getElementsByTagName(tagname)[0];
    a.async = 1;
    a.src = ga_link;
    m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');

ga('create', 'UA-69066956-1', 'auto');
ga(function(tracker) {
    var clientId = tracker.get('clientId'); // get client id from  Google Analytics
    document.cookie = "_ga_cid=" + clientId + "; path=/"; // save it to cookie _ga_cid
    document.cookie = "cid=" + clientId + "; path=/"; // save it to cookie cid
    ga('set', 'dimension1', clientId); //запись clientId для каждого пользователя
});
ga('send', 'pageview');
</script>
</body>
</html>