Skip to content

Instantly share code, notes, and snippets.

@dustinlarimer
dustinlarimer / README.md
Last active October 6, 2017 00:23
Github Analytics with Keen IO

Github Analytics with Keen IO

This script will create a series of webhooks to stream event data from your Github organization(s) to a Keen project.

Project ID & API Key

Login to Keen IO to create a project and grab the Project ID and Write Key from your project's Access page. Copy these into the keen.projectId and keen.writeKey fields of the config.json file included with this gist.

Github Access Token

@dustinlarimer
dustinlarimer / index.html
Last active December 19, 2016 23:57
Scroll-tracking with an unload listener
<html>
<head>
<meta charset="utf-8">
<script src="http://d26b395fwzu5fz.cloudfront.net/keen-tracking-1.0.1.js"></script>
</head>
<body style="height: 9000px;">
<h1>Open your developer console</h1>
<a href="./index.html">Test Page Unload</a>
<script>
/*
@dustinlarimer
dustinlarimer / index.html
Last active December 10, 2016 00:13
This example shows how to record Vimeo Player usage stats with Keen IO. Make sure to include your Keen IO Project ID and Write Key. If you don't have a Keen IO account, create one here for free: http://keen.io/signup
<html>
<head>
<meta charset="utf-8">
<script src="http://d26b395fwzu5fz.cloudfront.net/keen-tracking-1.0.1.js"></script>
<script src="https://player.vimeo.com/api/player.js"></script>
</head>
<body>
<iframe id="vimeo-player"
src="https://player.vimeo.com/video/76979871"
frameborder="0" height="360" width="640"
@dustinlarimer
dustinlarimer / index.html
Created December 9, 2016 23:50
This example shows how to record Youtube iFrame Player usage stats with Keen IO. Make sure to include your Keen IO Project ID and Write Key. If you don't have a Keen IO account, create one here for free: http://keen.io/signup
<html>
<head>
<meta charset="utf-8">
<script src="http://d26b395fwzu5fz.cloudfront.net/keen-tracking-1.0.1.js"></script>
</head>
<body>
<iframe id="youtube-iframe-player"
width="640" height="360"
src="https://www.youtube.com/embed/G5UBjF1z9hA?enablejsapi=1"
frameborder="0"
@dustinlarimer
dustinlarimer / index.html
Last active December 9, 2016 04:05
This example shows how to record VideoJS usage stats with Keen IO. Make sure to include your Keen IO Project ID and Write Key. If you don't have a Keen IO account, create one here for free: http://keen.io/signup
<html>
<head>
<meta charset="utf-8">
<script src="http://d26b395fwzu5fz.cloudfront.net/keen-tracking-1.0.1.js"></script>
<!-- VideoJS Assets -->
<link href="http://vjs.zencdn.net/5.8.8/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/5.8.8/video.js"></script>
</head>
<body>
@dustinlarimer
dustinlarimer / index.html
Last active December 9, 2016 03:06
This example shows how to record HTML5 Video Player usage stats with Keen IO. Make sure to include your Keen IO Project ID and Write Key. If you don't have a Keen IO account, create one here for free: http://keen.io/signup
<html>
<head>
<meta charset="utf-8">
<script src="http://d26b395fwzu5fz.cloudfront.net/keen-tracking-1.0.1.js"></script>
</head>
<body>
<!-- HTML5 Video Player -->
<div>
<button id="video-control">Play</button>
<br><br>
@dustinlarimer
dustinlarimer / index.html
Last active December 9, 2016 03:16
This example shows how to record Facebook Video Player usage stats with Keen IO. Make sure to include your Facebook App ID, as well as Keen IO Project ID and Write Key. If you don't have a Keen IO account, create one here for free: http://keen.io/signup
<html>
<head>
<meta charset="utf-8">
<script src="http://d26b395fwzu5fz.cloudfront.net/keen-tracking-1.0.1.js"></script>
</head>
<body>
<div id="fb-root"></div>
<script>
/*
Learn more about the Facebook Video Player API here:
# POST many events
$ curl https://api.keen.io/3.0/projects/<PROJECT_ID>/events \
    -H 'Authorization: <WRITE_KEY>' \
    -H 'Content-Type: application/json' \
    -d '{
      "purchases": [
        {
          "item_id": "f9802334-23423",
          "customer": "janet.username@gmail.com",
@dustinlarimer
dustinlarimer / tracking-plugin.js
Last active August 29, 2015 14:10
Auto-tracker
function _go(f){/in/.test(document.readyState)?setTimeout('_go('+f+')',9):f()}
_go(function(){
var COOKIE_KEY = "COOKIE-ID",
COOKIE_EXP = undefined, // 1000*60*60*24*365,
IS_KNOWN = false;
var CurrentSession = {},
wpMeta = WP_META || {},
interval;
@dustinlarimer
dustinlarimer / loader.js
Last active August 29, 2015 14:06
Refactored the keen-js async paste-in script, to make the namespace and version number more accessible :)
!function(i,o){i("Keen","/3.1.0/keen.min.js",o)}(function(a,b,c){var d,e,f;c["_"+a]={},c[a]=function(b){c["_"+a].clients=c["_"+a].clients||{},c["_"+a].clients[b.projectId]=this,this._config=b},c[a].ready=function(b){c["_"+a].ready=c["_"+a].ready||[],c["_"+a].ready.push(b)},d=["addEvent","setGlobalProperties","trackExternalLink","on"];for(var g=0;g<d.length;g++){var h=d[g],i=function(a){return function(){return this["_"+a]=this["_"+a]||[],this["_"+a].push(arguments),this}};c[a].prototype[h]=i(h)}e=document.createElement("script"),e.async=!0,e.src=b,f=document.getElementsByTagName("script")[0],f.parentNode.insertBefore(e,f)},this);
(function(i,o){i("Keen","/3.1.0/keen.min.js",o);}(function(t,h,x){
// t = context
// h = file
// x = context
// console.log(t,h,x===window);
var methods, script, tag;
// _Keen cache