Skip to content

Instantly share code, notes, and snippets.

@rebeccastandig
rebeccastandig / gist:8968570
Created February 13, 2014 02:18
How to generate a line chart for conversion analysis with Keen IO
<script type="text/javascript" charset="utf-8">
// Global Properties for Line Chart Viz
var chartHeight = 400
var chartWidth = 600
var lineWidth = 3
var chartAreaWidth = "60%"
var chartAreaLeft = "10%"
var xAxisLabelAngle = "45%"
@rebeccastandig
rebeccastandig / retention_line_chart.js
Last active October 25, 2017 21:03
How to generate a line chart for retention analysis with Keen IO
<script type="text/javascript" charset="utf-8">
// Global Properties for Line Chart Viz
var chartHeight = 400
var chartWidth = 600
var lineWidth = 3
var chartAreaWidth = "60%"
var chartAreaLeft = "10%"
var xAxisLabelAngle = "45%"
@rebeccastandig
rebeccastandig / delete_all_event_collections.py
Last active January 4, 2016 07:29
Quick Python script to delete all of your Keen IO event collections. Note: I have the script print out the response when you run a delete so you can see if it returns a 204. If not, something's wrong :) I'd just put some print statements in there and check to make sure it's on the project you want, etc, before actually deleting.
# -*- coding: utf-8 -*-
import requests, json
master_key = 'your_keen_master_key'
def get_events():
return requests.get("https://api.keen.io/3.0/projects?api_key=your_keen_master_key").json()
def del_events():
@rebeccastandig
rebeccastandig / custom_keen_number.js
Last active January 3, 2016 07:28
How to create a Keen Number that divides the results of two different queries.
Keen.onChartsReady(function(){
//Create a Metric containing our total number of logins.
var myMetric = new Keen.Metric("logins", {
analysisType: "count"
});
//Create a Metric containing our total number of registers.
var myMetric2 = new Keen.Metric("registers", {
analysisType: "count"
@rebeccastandig
rebeccastandig / custom_keen_line_chart.js
Last active January 3, 2016 07:19
How to create a Keen Line Chart with cumulative data.
Keen.onChartsReady(function(){
var loginsPreviousWeek = new Keen.Series("logins", {
analysisType: "count",
timeframe: "previous_7_days",
interval: "daily"
});
//Get the result of the query and add the results cumulatively.
loginsPreviousWeek.getResponse(function(response){
@rebeccastandig
rebeccastandig / display_block_keen.js
Last active January 3, 2016 04:19
Ways around display:block in Keen IO's JS SDK. The container that’s inserted is a div, so it is display block by default. We’re adding it inline as well, which means it can't be overridden.In the meantime, there is a way to get around it. You already need to specify a div (with an ID) for where to insert the Keen number widget, so you can just a…
First way uses display: inline-block
<style>
/* required to remove arbitrary whitespace
* between child elements that are inline-block
*/
.dashboard {
font-size: 0px;
}
.number {
display: inline-block;