diff --git a/tarteaucitron.js b/tarteaucitron.js index c638cfb..74f097f 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -6,8 +6,9 @@ var scripts = document.getElementsByTagName('script'), cdn = path.split('/').slice(0, -1).join('/') + '/'; var tarteaucitron = { - "showAlertSmall": true, // show the small banner on bottom right ? - "autoOpen": false, // auto open the panel with #tarteaucitron hash ? + "showAlertSmall": true, // show the small banner on bottom right? + "autoOpen": false, // auto open the panel with #tarteaucitron hash? + "grayArea": false, // activate the features of the gray area? "cdn": cdn, "user": {}, "lang": {}, @@ -184,7 +185,9 @@ var tarteaucitron = { tarteaucitron.state[service.key] = false; tarteaucitron.userInterface.color(service.key, false); } else if (!isResponded) { - if (typeof service.fallback === 'function') { + if (typeof service.grayJs === 'function' && tarteaucitron.grayArea === true) { + service.grayJs(); + } else if (typeof service.fallback === 'function') { service.fallback(); } } diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index 99c2889..e4639c3 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -145,6 +145,25 @@ tarteaucitron.services.analytics = { } }); }, + "grayJs": function () { + "use strict"; + window.GoogleAnalyticsObject = 'ga'; + window.ga = window.ga || function () { + window.ga.q = window.ga.q || []; + window.ga.q.push(arguments); + }; + window.ga.l = new Date(); + + tarteaucitron.addScript('//www.google-analytics.com/analytics.js', '', function () { + ga('create', tarteaucitron.user.analyticsUa, {'cookieExpires': 86400}); + ga('set', 'anonymizeIp', true); + ga('set', 'forceSSL', true); + ga('send', 'pageview'); + if (typeof tarteaucitron.user.analyticsMore === 'function') { + tarteaucitron.user.analyticsMore(); + } + }); + }, "fallback": function () { "use strict"; var cookies = ['_ga', '_gat', '__utma', '__utmb', '__utmc', '__utmt', '__utmz'];