Skip to main content

Create funnel

Enterprise

This endpoint is part of Countly Enterprise. To get access, contact sales or compare versions. Existing customers can reach the support portal with questions.

Endpoint

/i/funnels/add

Overview

Creates a new funnel definition.

Authentication

Pass api_key or auth_token as a query parameter, or send countly-token as a header. See Authentication.

Permissions

Requires funnels Create permission.

Request Parameters

ParameterTypeRequiredDescription
app_idStringYesTarget app ID.
funnel_nameStringYesFunnel display name.
funnel_descStringNoFunnel description.
funnel_typeStringNoFunnel type. Defaults to session-independent.
stepsJSON String (Array)YesOrdered step events.
queriesJSON String (Array)NoPer-step query objects/strings.
queryTextsJSON String (Array)NoPer-step query text labels.
stepGroupsJSON String (Array)NoPer-step grouping config.
api_keyStringConditionalRequired if auth_token is not provided.
auth_tokenStringConditionalRequired if api_key is not provided.

Examples

/i/funnels/add?
app_id=64f5c0d8f4f7ac0012ab3456&
funnel_name=Purchase Funnel&
funnel_desc=Product view to purchase&
funnel_type=session-independent&
steps=["Product View","Add to Cart","Purchase"]&
queries=["{}","{}","{}"]&
queryTexts=["All Users","All Users","All Users"]&
stepGroups=[{"c":"and"},{"c":"and"},{"c":"and"}]
/i/funnels/add?
app_id=64f5c0d8f4f7ac0012ab3456&
funnel_name=Checkout Funnel (Same Session)&
funnel_type=same-session&
steps=["[CLY]_session","Checkout Start","Purchase"]&
queries=["{}","{\"cc\":\"US\"}","{}"]

Response

Success Response

{
"result": "67f1c22912df5acb8f8d5caaf0f89a31"
}

Response Fields

FieldTypeDescription
resultStringCreated funnel ID (md5 hash string).

Error Responses

  • 400
{
"result": "Not enough args"
}
  • 400
{
"result": "Duplicate events in steps are not allowed"
}

Behavior

  • Parses steps, queries, queryTexts, and stepGroups JSON-string parameters.
  • For queries, object entries are converted to JSON strings before save.
  • Rejects duplicate step events except special cases [CLY]_view and [CLY]_session.
  • Sets default funnel_type to session-independent when omitted.
  • Creates funnel document with creator and creation timestamp.
Implementation details

Database Collections

CollectionUsed forData touched by this endpoint
countly.funnelsEndpoint data sourceStores endpoint-related records this endpoint reads or modifies.
countly.systemlogsAudit trailContains system action records used by this endpoint for audit output or audit writes.