Skip to content

Instantly share code, notes, and snippets.

@wetzler
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wetzler/cf03b70696136f874643 to your computer and use it in GitHub Desktop.
Save wetzler/cf03b70696136f874643 to your computer and use it in GitHub Desktop.
put all queries under one function
<!DOCTYPE html>
<html lang='en'>
<head>
<title>Retention</title>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.js'></script>
<script src="https://d26b395fwzu5fz.cloudfront.net/latest/keen.min.js"></script>
<script>
// This brings in the Keen javascript library
!function(a,b){if(void 0===b[a]){b["_"+a]={},b[a]=function(c){b["_"+a].clients=b["_"+a].clients||{},b["_"+a].clients[c.projectId]=this,this._config=c},b[a].ready=function(c){b["_"+a].ready=b["_"+a].ready||[],b["_"+a].ready.push(c)};for(var c=["addEvent","setGlobalProperties","trackExternalLink","on"],d=0;d<c.length;d++){var e=c[d],f=function(a){return function(){return this["_"+a]=this["_"+a]||[],this["_"+a].push(arguments),this}};b[a].prototype[e]=f(e)}var g=document.createElement("script");g.type="text/javascript",g.async=!0,g.src="https://d26b395fwzu5fz.cloudfront.net/3.0.4/keen.min.js";var h=document.getElementsByTagName("script")[0];h.parentNode.insertBefore(g,h)}}("Keen",this);
// This sets up a Keen client
var keenClient = new Keen({
projectId: "proj",
readKey: "key"
});
Keen.ready(function(){
var pin_query = new Keen.Query("sum", {
eventCollection: "scraping",
timeframe: "today",
targetProperty: "downloads.pins_added",
interval: "hourly"
});
keenClient.draw(pin_query, document.getElementById("pins_by_hour"), {
title:'Showing pins added today',
width:700
});
// });
//
// Keen.ready(function(){
var user_query = new Keen.Query("sum", {
eventCollection: "users",
timeframe: "this_week",
targetProperty: "signups.user_id",
interval: "hourly"
});
keenClient.draw(user_query, document.getElementById("users_by_hour"), {
title:'Showing users added this week',
width:700
});
// });
//
// Keen.ready(function(){
var domain_query = new Keen.Query("sum", {
eventCollection: "domains",
timeframe: "this_week",
targetProperty: "adds.domain_id",
interval: "hourly"
});
keenClient.draw(domain_query, document.getElementById("domains_by_hour"), {
title:'Showing domains added this week',
width:700
});
});
</script>
</head>
<body>
<div id="pins_by_hour"></div>
<div id="users_by_hour"></div>
<div id="domains_by_hour"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment