Skip to content

Instantly share code, notes, and snippets.

@wetzler
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wetzler/40459f02ab3da0cdfe22 to your computer and use it in GitHub Desktop.
Save wetzler/40459f02ab3da0cdfe22 to your computer and use it in GitHub Desktop.
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:
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:
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
"event_collection":"purchase",
"actor_property":"user.id",
"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
"event_collection":"clicks",
"actor_property":"uuid",
"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
"operator":"eq",
"property_value":"444"
}
]
}
]
Output:
{
"result":[
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:
https://keen.io/docs/data-analysis/funnels/
https://keen.io/blog/95135161401/beyond-funneldamentals-a-more-powerful-behavior
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment