Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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:
1) we are tracking all raw purchases in Keen IO as they flow in
2) all clicks are also tracked in Keen IO (ideally in a separate collection)
3) both those events have user ids
This funnel query will allow us to find all the users who make a purchase recently and which ones had clicks:
steps = [
{ // Step 1 -- Find all of the uuids who had purchases the last hour
"with_actors": false,
"timeframe": {
"start" : "2014-11-24T19:00:00.000Z",
"end" : "2014-11-24T20:00:00.000Z"
{ // Step 2 -- Of those, find out which ones had clicks
"timeframe": "last_10_days",
"with_actors": true, // makes it so that the funnel outputs all of the relevant _ids
"filters": [
"property_name":"campaignId", // apply arbitrary filters as needed
9375, // Unique Users Who Purchased
203 // Unique Users Who Purchased and Had Clicks in CampaignID 444
"actors": [
null, // Step 1 Actors (not returned unless specified)
["234234as3f", "0293094323ss3", "2309d0je9w", ...] // Step 2 Actors -- all of the users who had clicks!
"steps":[<info about steps>]
More about funnels here:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment