From 5aadb5ab4f4a76b04a37034b6ca084a0908afb1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Sun, 25 Feb 2018 22:42:53 +0100 Subject: [PATCH] Google Analytics events --- server/public/assets/css/style.css | 2 +- server/public/assets/js/channel.js | 3 +-- server/public/assets/js/functions.js | 1 + server/public/assets/js/list.js | 4 +++ server/public/assets/js/listeners.js | 32 ++++++++++++++++++++++-- server/public/partials/footer.handlebars | 6 ++--- 6 files changed, 40 insertions(+), 8 deletions(-) diff --git a/server/public/assets/css/style.css b/server/public/assets/css/style.css index 2c97fab5..c9ac75ce 100755 --- a/server/public/assets/css/style.css +++ b/server/public/assets/css/style.css @@ -575,7 +575,7 @@ footer{ right:0px; } -.help-button-footer{ +.help-button-footer, .embed-button-footer, .contact-button-footer{ width:17em; background: #1e88e5; border-radius: 2px; diff --git a/server/public/assets/js/channel.js b/server/public/assets/js/channel.js index 6a7923e1..74fcd25b 100644 --- a/server/public/assets/js/channel.js +++ b/server/public/assets/js/channel.js @@ -105,6 +105,7 @@ var Channel = { $(".offline_switch_class")[0].checked = true; change_offline(true, offline); } + if(!Helper.mobilecheck() && ($("#alreadychannel").length === 0 || !Hostcontroller.old_id || $("#code-text").text().toUpperCase() == "ABBADUR")) setup_host_initialization(); if($("#alreadychannel").length === 0 || Helper.mobilecheck()){ setup_youtube_listener(); @@ -197,8 +198,6 @@ var Channel = { socket.emit("get_history", {channel: chan.toLowerCase(), all: false}); socket.emit("get_history", {channel: chan.toLowerCase(), all: true}); - if(!Helper.mobilecheck() && ($("#alreadychannel").length === 0 || !Hostcontroller.old_id || $("#code-text").text().toUpperCase() == "ABBADUR")) setup_host_initialization(); - if(!Helper.msieversion() && !Helper.mobilecheck()) Notification.requestPermission(); $(".search_input").focus(); diff --git a/server/public/assets/js/functions.js b/server/public/assets/js/functions.js index e867c075..46a7029b 100644 --- a/server/public/assets/js/functions.js +++ b/server/public/assets/js/functions.js @@ -252,6 +252,7 @@ function embed_code(autoplay, width, height, color, embed_code){ function change_offline(enabled, already_offline){ Crypt.set_offline(enabled); offline = enabled; + ga('send', 'event', "button-click", "offline", "", offline ? 1 : 0); socket.emit("offline", {status: enabled, channel: chan != undefined ? chan.toLowerCase() : ""}); if(!Helper.mobilecheck()) { $("#offline-mode").tooltip('remove'); diff --git a/server/public/assets/js/list.js b/server/public/assets/js/list.js index 87476993..26032f2c 100755 --- a/server/public/assets/js/list.js +++ b/server/public/assets/js/list.js @@ -560,6 +560,8 @@ var List = { }, exportToSpotify: function() { + ga('send', 'event', "export", "spotify"); + $.ajax({ type: "GET", url: "https://api.spotify.com/v1/me", @@ -742,6 +744,8 @@ var List = { }, exportToYoutube: function() { + ga('send', 'event', "export", "youtube"); + var request_url = "https://www.googleapis.com/youtube/v3/playlists?part=snippet"; $(".exported-list-container").removeClass("hide"); $("#playlist_loader_export").removeClass("hide"); diff --git a/server/public/assets/js/listeners.js b/server/public/assets/js/listeners.js index 2eb9bfc0..8cc23911 100755 --- a/server/public/assets/js/listeners.js +++ b/server/public/assets/js/listeners.js @@ -422,7 +422,6 @@ $(document).on("click", "#offline-mode", function(e){ } else{ change_offline(false, offline); } - }); $(document).on("submit", "#thumbnail_form", function(e){ @@ -606,6 +605,8 @@ $(document).on("click", ".first_page", function(e){ $(document).on("click", ".donate-button", function(e) { e.preventDefault(); + ga('send', 'event', "button-click", "donate"); + $("#donate").modal("open"); }); @@ -706,6 +707,7 @@ $(document).on("click", "#listExport", function(e){ access_token_data_youtube = {}; }, access_token_data_youtube.expires_in * 1000); List.exportToYoutube(); + } else { access_token_data_youtube = ""; console.error("Nonce doesn't match"); @@ -753,6 +755,8 @@ $(document).on("submit", "#listImport", function(e){ document.getElementById("import").disabled = true; $("#import").addClass("hide"); $("#playlist_loader").removeClass("hide"); + + ga('send', 'event', "import", "youtube"); } else { before_toast(); Materialize.toast("It seems you've entered a invalid url.", 4000); @@ -774,6 +778,8 @@ $(document).on("submit", "#listImportSpotify", function(e){ $("#import_spotify").addClass("hide"); $("#playlist_loader_spotify").removeClass("hide"); + ga('send', 'event', "import", "spotify"); + Search.importSpotifyPlaylist('https://api.spotify.com/v1/users/' + user + '/playlists/' + playlist_id + '/tracks'); } else { before_toast(); @@ -870,6 +876,26 @@ $(document).on("click", "#channel-share-modal", function(){ $("#channel-share-modal").modal("close") }); +$(document).on("click", ".shareface", function(e) { + ga('send', 'event', "button-click", "share-facebook"); +}); + +$(document).on("click", ".android-image-link", function() { + ga('send', 'event', "button-click", "android-playstore-link"); +}); + +$(document).on("click", "#twitter-code-link", function() { + ga('send', 'event', "button-click", "share-twitter"); +}); + +$(document).on("click", ".help-button-footer", function() { + ga('send', 'event', "button-click", "help-footer"); +}); + +$(document).on("click", "#embed-button", function() { + ga('send', 'event', "button-click", "embed-channel", "channel-name", chan.toLowerCase()); +}) + $(document).on("click", ".chat-link", function(e){ chat_active = true; unseen = false; @@ -1159,7 +1185,9 @@ $(document).on("click", ".generate-channel-name", function(e) { $(".room_namer").val(""); $(".room-namer").val(response); } - }) + }); + + ga('send', 'event', "button-click", "generate-channel"); }); $(document).keydown(function(event) { diff --git a/server/public/partials/footer.handlebars b/server/public/partials/footer.handlebars index ef33ae5a..de250918 100644 --- a/server/public/partials/footer.handlebars +++ b/server/public/partials/footer.handlebars @@ -18,12 +18,12 @@
  • - + codeEMBED
  • - + emailCONTACT
  • @@ -48,7 +48,7 @@
  • - + Get it on Google Play