Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jice-lavocat/5fbac33b9bb58251b2bfa96f04be811f to your computer and use it in GitHub Desktop.
Save jice-lavocat/5fbac33b9bb58251b2bfa96f04be811f to your computer and use it in GitHub Desktop.
Greasemonkey script that plays a sound every time you get a new active user in google analytics realtime view.
// ==UserScript==
// @name Google Analytics Realtime Alerts
// @namespace http://mobilecoder.wordpress.com
// @version 1.0
// @description Plays a sound when you get a new user, you can change the sound by hosting your own file on dropbox or other web location
// @match https://www.google.com/analytics/web/?hl=en#realtime*
// ==/UserScript==
// Your custom sound goes here
mCoinSound = new Audio("https://dl.dropbox.com/u/7079101/coin.mp3");
// But don't touch this
mActiveUsers = 0;
setInterval(getActiveUsers, 1);
function getActiveUsers(){
var count = parseInt(document.getElementById("ID-overviewCounterValue").innerText);
if(count > mActiveUsers){
mCoinSound.play();
}
mActiveUsers = count;
}
@jice-lavocat
Copy link
Author

jice-lavocat commented Mar 10, 2018

In hugo blog post :

var url= ["https", "://soundbible", ".com/grab.php?id=1446&type=mp3"].join("");
mCoinSound = new Audio(url);
mActiveUsers = 0;
setInterval(getActiveUsers, 1);
function getActiveUsers(){
    var count = parseInt(document.getElementById("ID-overviewCounterValue").innerText);
    if(count > mActiveUsers){
	mCoinSound.play();        
    }
    mActiveUsers = count;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment