Skip to content

Instantly share code, notes, and snippets.

View wetzler's full-sized avatar

Michelle Wetzler wetzler

  • Bay Area, California
View GitHub Profile
@wetzler
wetzler / gist:4478332
Last active December 10, 2015 18:58
Kickfolio's (minified) code to embed Keen IO charts in their user dashboards. They have 3 line charts (last 7 days, last 24 hours, and last 4 weeks) which show the number of user "connect" sessions for a given app (identified by the filter app.PublicKey). For more context, see this blog post: http://blog.keen.io/post/39950174904/kickfolio-uses-k…
Keen.configure(window.ENV.keenProjectId,window.ENV.keenApiKey),
Keen.onChartsReady(function(){
var e=new Keen.Series("connect",{
analysisType:"count",
timeframe:"last_7_days",
interval:"daily"
}),
t=new Keen.Series("connect",{
@wetzler
wetzler / gist:5210061
Last active December 15, 2015 05:38
This script creates a retention funnel query in Keen IO and outputs both the funnel query name and the results of the query.
require 'rubygems'
require 'net/http'
require 'net/https'
require 'uri'
require 'json'
require 'date'
require 'active_support/all' #for datetime calculation e.g. weeks.ago.at_beginning_of_week
# Keen Project Info
$projectID = "your project ID"
@wetzler
wetzler / gist:6629918
Last active February 23, 2019 21:31
a key with magical powers
d90e5b5598497773de1c57407dd54d65934ba1b5911f6f47311d3c729f510bb5c295284780017a56f17e49234f19c009bfa57f7941413a5dd3c282d7db3692a192b58ea926b637cdcd11377e1e74086641e0672c8b3406aeed49d63ee0a3a3d3751ae7744f08b999df38ca2ccdbb9a2c
@wetzler
wetzler / gist:6816497
Last active December 24, 2015 14:59
Here's how you can get query results for two Keen IO series, in parallel, and then combine them in one multiline chart.I really want to rewrite this to run N queries at a time, but this works for now.
Keen.configure({
projectId: id,
readKey: key
});
// Timeframe parameters for queries
var timeframe = "last_14_days"
var interval = "daily"
Keen.onChartsReady(function(){
@wetzler
wetzler / gist:6909882
Last active May 16, 2020 13:13
This gist shows you how to run a retention analysis. I blogged about how to run a retention analysis here: https://keen.io/blog/47823687779/how-to-do-a-retention-analysis/
require 'rubygems'
require 'keen'
require 'json'
require 'date'
require 'active_support/all' #for datetime calculation e.g. weeks.ago.at_beginning_of_week
require 'simple_xlsx' #for outputting excel files
require 'cgi' #for URL encoding
#================================oOo===================================
@wetzler
wetzler / gist:7541840
Created November 19, 2013 07:56
This script runs a group_by query and outputs the results to a CSV
require 'rubygems'
require 'net/http'
require 'net/https'
require 'keen'
require 'uri'
require 'json'
require 'date'
# This script runs a group_by query and outputs the results to a CSV
#================================oOo===================================
@wetzler
wetzler / gist:8739951
Created January 31, 2014 18:46
workaround for saved queries drawing weirdness
var query = new Keen.SavedQuery("activity_09_2013");
query.getResponse(function(response){
console.log(response.result);
// Call Michelle's gross function
drawMyLineChart(response, "daily", div , title)
});
function drawMyLineChart(response, interval, div, title) {
@wetzler
wetzler / gist:8986385
Created February 13, 2014 23:44
Pseudocode for making a cumulative line chart with Keen IO series data. Use this to make a running total of users, for example. The gist assumes that the timeframe being queried includes all of the data.
Keen.onChartsReady(function() {
var series = new Keen.Series("registrations", {
analysisType: "count",
timeframe: "last_30_weeks",
interval: "weekly"
});
series.getResponse(function(response){
keenData = response.result;
@wetzler
wetzler / gist:8986843
Last active August 29, 2015 13:56
How to get the total amount refunded in Stripe using Keen IO
Keen.onChartsReady(function() {
var metric = new Keen.Metric("Stripe_Events", {
analysisType: "sum",
targetProperty: "data.object.amount_refunded",
filters: [{"property_name":"type","operator":"eq","property_value":"charge.refunded"}]
});
metric.draw(document.getElementById("someDiv"));
});
@wetzler
wetzler / gist:9127225
Last active August 29, 2015 13:56
Divide to series queries (line charts) from Keen IO and chart the resulting line chart.
Keen.onChartsReady(function() {
var totalRevenueSeries = new Keen.Series("transactions", {
analysisType: "sum",
timeframe: "last_30_days",
interval: "daily",
targetProperty: "amount"
});
var totalActiveUsersSeries = new Keen.Series("plays", {