Skip to main content
Version: 25.03

/i/campaign/click

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/campaign/click/{campaign_id}

Overview​

Tracking link for a campaign. Records a click for the campaign and redirects the visitor to the campaign's destination link, chosen by the visitor's platform.

Authentication​

  • No API key or token is required. The campaign is identified by the ID in the URL path.

Permissions​

  • None. The endpoint is meant to be opened by end users following a campaign link.

Request Parameters​

ParameterTypeRequiredDescription
campaign_idStringYesCampaign ID, as the last path segment of the URL.
segmentsJSON String (Object)NoExtra values to record with the click. Keys starting with aid_ are treated as advertising identifiers; other keys become click segments. Invalid JSON is ignored.
ip_addressStringNoIP address to use for country and city lookup instead of the request's own IP.
ignoreAnyNoWhen present, the click is not recorded; the visitor is redirected to the campaign's default link directly.
testAnyNoWhen present, the response is JSON with the resulting link instead of a redirect. The click is still recorded, with a new campaign-user ID instead of the one from the cookie.
timestampNumberNoUnix timestamp of the click, used as the click time and for the metric date. Defaults to the current time.

The platform, browser, language, referer and location of the click are taken from the request's User-Agent, Accept-Language and Referer headers and IP address.

Examples​

/i/campaign/click/campaign-summer-2026
/i/campaign/click/campaign-summer-2026?test=1

Response​

Success Response​

By default the response is an HTTP 302 redirect with these headers:

HeaderDescription
LocationDestination link for the visitor's platform.
Set-CookieSets a cookie named after the campaign ID holding the campaign-user ID.
Campaign-UserThe campaign-user ID.

With test set, the response is JSON:

{
"link": "https://example.com/landing"
}

With ignore set (and test set), the response is the same JSON; without test, it is a 302 with only the Location header.

If the app has a redirect URL configured, the response is a 302 to that URL with the request path and query appended, and the click is not recorded here.

Response Fields​

FieldTypeDescription
linkStringResolved destination link (only in test responses).

Error Responses​

Status Code: 404 Not Found (plain text)

Campaign not Found

Status Code: 404 Not Found (plain text)

App not Found

Behavior​

  • Looks up the campaign by ID. Campaigns without an app are treated as not found.
  • Picks the destination from the campaign's per-platform links, falling back to its default link.
  • For App Store links, adds cid (campaign name) when missing. For Google Play or market: links, adds or extends referrer with countly_cid and countly_cuid.
  • For other links, adds cly_id and cly_uid when the Attribution pass_campaign setting is on.
  • When the Attribution pass_query setting is on, adds the segments values as query parameters to the link, whatever its type.
  • If the platform has a custom-scheme link configured, the redirect goes to a Countly /campaign/<platform>/ page that receives the link and the scheme as url and scheme query parameters.
  • Stores a click fingerprint (app, IP, platform) and upserts the campaign user, then records an aclk (click) metric for the campaign. The first click of a campaign user also counts as a unique click (clk).
  • With test, the click is recorded in the same way; only the response differs.
  • Adds one click data point to server stats.
  • With ignore, the campaign's default link is always used, unmodified.
Implementation details

Database Collections

CollectionUsed forData touched by this endpoint
countly.campaignsCampaign storageReads the campaign and its links.
countly.appsApp lookupReads the app and its redirect URL.
countly.attributionClick fingerprintsUpserts a click record.
countly.campaign_users{appId}Campaign usersUpserts the campaign user for the click.
countly.campaigndataCampaign metricsRecords the click metric.