This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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",{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------------------- | |
Line Chart with Cumulative Data | |
------------------------------- | |
This is an example for how you can create a line chart with data that is shown cumulatively. | |
.. note:: | |
This example is current for our JS SDK v2.1.2 only. It does not apply to v3+ | |
.. code-block:: javascript |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Keen.onChartsReady(function() { | |
var series = new Keen.Series("registrations", { | |
analysisType: "count", | |
timeframe: "last_30_weeks", | |
interval: "weekly" | |
}); | |
series.getResponse(function(response){ | |
keenData = response.result; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Keen=Keen||{configure:function(e){this._cf=e},addEvent:function(e,t,n,i){this._eq=this._eq||[],this._eq.push([e,t,n,i])},setGlobalProperties:function(e){this._gp=e},onChartsReady:function(e){this._ocrq=this._ocrq||[],this._ocrq.push(e)}};(function(){var e=document.createElement("script");e.type="text/javascript",e.async=!0,e.src=("https:"==document.location.protocol?"https://":"http://")+"dc8na2hxrj29i.cloudfront.net/code/keen-2.1.0.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})(); | |
Keen.configure({ // configure the Keen Client | |
projectId: projectId, | |
readKey: readKey | |
}); | |
Keen.onChartsReady(function() { | |
var numLevels = 10 | |
var funnelSteps = prepareFunnel(numLevels) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'dotenv' | |
require 'keen' | |
# Don't forget to specify your Keen Master Key, Ready Key, and Project ID in your environment variables! | |
# Reference: https://github.com/keenlabs/keen-gem | |
Dotenv.load | |
# allow timeframe to be specified via the command line | |
# usage: ruby collection_counts.rb previous_7_days |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | |
"steps":[ | |
{ | |
"event_collection":"signed_up", | |
"actor_property":"user.id" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | |
https://api.keen.io/3.0/projects/<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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// example event model | |
// User_Created_Event = { | |
// "full_name": "Macy Bode", | |
// "communities": [6,7,8], | |
// "email": "dev@dev.com" | |
// }, | |
// Find the number of users in Community 6 or 7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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", { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang='en'> | |
<head> | |
<title>Send Event Test</title> | |
<script type="text/javascript"> | |
!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); | |
</script> | |
<script> | |
var logger = new Keen({ |