diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index de910e4..4b2340e 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -2273,3 +2273,47 @@ tarteaucitron.services.matomo = { tarteaucitron.addScript(tarteaucitron.user.matomoHost + 'piwik.js', '', '', true, 'defer', true); } }; + +// Hotjar + +/* + 1. Set the following variable before the initialization : + + tarteaucitron.user.hotjarId = YOUR_WEBSITE_ID; + tarteaucitron.user.HotjarSv = XXXX; // Can be found in your website tracking code as "hjvs=XXXX" + + 2. Push the service : + + (tarteaucitron.job = tarteaucitron.job || []).push('hotjar'); + + 3. HTML + You don't need to add any html code, if the service is autorized, the javascript is added. otherwise no. + + + */ +tarteaucitron.services.hotjar = { + "key": "hotjar", + "type": "analytic", + "name": "Hotjar", + "uri": "https://help.hotjar.com/hc/en-us/sections/115003204947-What-is-Hotjar-", + "needConsent": true, + "cookies": [], + "js": function () { + "use strict"; + if (tarteaucitron.user.hotjarId === undefined || tarteaucitron.user.HotjarSv === undefined) { + return; + } + + window.hj = window.hj || function() { + (window.hj.q = window.hj.q || []).push(arguments) + }; + window._hjSettings = { + hjid: tarteaucitron.user.hotjarId, + hjsv: tarteaucitron.user.HotjarSv + }; + + var uri = 'https://static.hotjar.com/c/hotjar-'; + var extension = '.js?sv='; + tarteaucitron.addScript(uri + window._hjSettings.hjid + extension + window._hjSettings.hjsv); + } +};