diff --git a/script/public/analytics.js b/script/public/analytics.js new file mode 100644 index 00000000..083dfa26 --- /dev/null +++ b/script/public/analytics.js @@ -0,0 +1,22 @@ +function loadGoogleAnalytics(){ + window.dataLayer = window.dataLayer || []; + function gtag() { + dataLayer.push(arguments); + } + gtag('js', new Date()); + gtag('config', 'UA-27327609-3'); +} + +function loadGoogleTagManager() { + (function(i,s,o,g,r,a,m){ + i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ + (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), + m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) + }) + (window,document,'script','https://www.google-analytics.com/analytics.js','ga'); + ga('create', 'UA-27327609-3', 'auto'); + ga('send', 'pageview'); +} + +loadGoogleAnalytics(); +loadGoogleTagManager(); \ No newline at end of file diff --git a/script/public/index.html b/script/public/index.html index bb14d42a..3be3d024 100644 --- a/script/public/index.html +++ b/script/public/index.html @@ -2,6 +2,10 @@ TDT Channels - Marc Vila + + + + @@ -150,6 +154,13 @@ clearResolutions(); getResolution(channelToReproduce, updateResolution); } + + ga('send', { + hitType: 'event', + eventCategory: 'Video', + eventAction: 'play', + eventLabel: channelToReproduce + }); } function reproduceAudio(channelToReproduce) { @@ -178,6 +189,13 @@ // Show a UI element to let the user manually start playback. }); } + + ga('send', { + hitType: 'event', + eventCategory: 'Audio', + eventAction: 'play', + eventLabel: channelToReproduce + }); } function reproducePLSFromUrl(data) {