Skip to content

Instantly share code, notes, and snippets.

@error454
Last active January 13, 2018 16:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save error454/5272856 to your computer and use it in GitHub Desktop.
Save error454/5272856 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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment