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 / keen_io_web_autocollector_tracking_snippet.js
Last active April 19, 2017 18:57
Keen IO Auto-Collection for Web
<script type="text/javascript">
function createKeenWebAutoCollector(){window.keenWebAutoCollector=window.KeenWebAutoCollector.create({projectId:'<YOUR_PROJECT_ID>',writeKey:'<YOUR_WRITE_KEY',onloadCallbacks:window.keenWebAutoCollector.onloadCallbacks}),window.keenWebAutoCollector.loaded()}function initKeenWebAutoCollector(){window.keenWebAutoCollector.domReady()?window.createKeenWebAutoCollector():document.addEventListener("readystatechange",function(){window.keenWebAutoCollector.domReady()&&window.createKeenWebAutoCollector()})}window.keenWebAutoCollector={onloadCallbacks:[],onload:function(a){this.onloadCallbacks.push(a)},domReady:function(){return["ready","complete"].indexOf(document.readyState)>-1}};
<script async type="text/javascript" src="" onload="initKeenWebAutoCollector()"></script>
wetzler / Outline
Created April 14, 2017 17:35
example outline
Announcing Drop-in Analytics: Usage Dashboards for JavaScript Apps in Seconds
1. The problem: Analytics instrumentation takes time, getting to baseline "hello world" is clutch
2. The solution
a. Now you can drop in code to instantly see and explore basic engagement data
b. Here are examples of the usage analytics you can do with this
3. How you can use it
a. Here is how you setup the data collection
wetzler / Code Samples for FB Ads
Created February 9, 2017 21:27
Code Samples for FB Ads
trial_step_complete_tutorial = {
"trial" : {
"name" : "AppSpandexTrial",
"day_in_trial": 2,
"trial_total_duration_in_days": 14,
"user" : {
"visitor_id": "029309n90nf0w9f3n4qf2nf",
"email": "",
signup_flow = new Keen.Query("funnel", {
timeframe: {
start: "2015-07-01T07:00:00.000Z" // analyze events after this date
steps: [
event_collection: "view_page",
actor_property: "visitor_id",
filters: [
wetzler / gist:e9f0bdf8271a60f5e8dd
Created April 7, 2015 17:08
Count event totals for all of your Keen collections
require 'dotenv'
require 'keen'
# Don't forget to specify your Keen Master Key, Ready Key, and Project ID in your environment variables!
# Reference:
# allow timeframe to be specified via the command line
# usage: ruby collection_counts.rb previous_7_days
wetzler / gist:29e830f83d3b4caa83f4
Last active August 29, 2015 14:16
Keen IO OR Funnel Logic
Say you want to know, of all of the users who signed up, how many CREATED a post _OR_ RESPONDED to a post?
There is no built-in "OR" functionality in Keen IO funnels, but there is a way to use a little bit of logic to get the same result.
This imaginary funnel's steps might look like this:
wetzler / gist:40459f02ab3da0cdfe22
Last active August 29, 2015 14:11
AdTech Funnel Example - Click and Purchase Conversion, Attribution Analysis
Funnels are a way to do mass lookups of users to see which ones who did X also did Y.
Funnels are Keen IO queries formatted like this:<project_id>/queries/funnel?api_key=<read_key>&steps=<[step1, step2, step3...]>
Each 'step' is an action performed by the actor.
Say you want to know if a thousands of users who made a purchase had previously clicked on something on your site.
As an alternative checking if each user did an action, we can lookup a huge group at once using Funnels.
Below is a funnel example that can be done as long as the following are true:
wetzler / gist:bf72167d348be7304e97
Created December 8, 2014 03:56
How to use multiple counts to achieve an OR filter on arrayed values in Keen IO (even though we don't recommend arrays if possible!)
// example event model
// User_Created_Event = {
// "full_name": "Macy Bode",
// "communities": [6,7,8],
// "email": ""
// },
// Find the number of users in Community 6 or 7
wetzler / gist:15204426171990e5ceb3
Last active August 29, 2015 14:10
Keen IO Query Example: Users who did X action C times from D1 to D2, with filters
# Scenario:
We want all users who did event X,
where event X had property Y and Z with values A and B,
where event X happened C times within the dates D1 and D2.
# Solution:
You can arrive at the final result using this query:
var users_who_did_x = new Keen.Query("count", {