Appfiliate Docs
appfiliate.io

Tracking Links

Every creator in your affiliate program gets unique tracking links. When a user clicks one, Appfiliate captures attribution signals and redirects them to the correct app store -- all in a single fast hop through a Cloudflare Worker.


Link format

Each tracking link follows this pattern:

Tracking link format
https://track.appfiliate.io/c/{code}

The code is a 6-character alphanumeric identifier that uniquely identifies the link. Each creator can have multiple links -- typically one per platform they promote on (TikTok, Instagram, YouTube, etc.) -- so you can see which channels are driving the most installs.

Example links for a creator
https://track.appfiliate.io/c/Ab3xK9    (TikTok bio)
https://track.appfiliate.io/c/Qm7nP2    (Instagram story)
https://track.appfiliate.io/c/Zt1wR5    (YouTube description)

What happens when a link is clicked

The entire click flow is handled by a Cloudflare Worker deployed at track.appfiliate.io. Here is what happens in sequence:

1

Worker receives the request

The Cloudflare Worker matches the URL pattern /c/:code and extracts the link code.

2

Captures attribution signals

The worker reads these values from the incoming request:

  • IP address -- via cf-connecting-ip header
  • User-Agent -- device model, OS, and browser
  • Accept-Language -- browser language preference
  • Referer -- the page that linked to the tracking URL (or "direct")
  • TLS fingerprint -- JA3 hash from Cloudflare Bot Management
  • Country -- from Cloudflare's geolocation
3

Looks up link data

The worker fetches the link's configuration (App Store URL, Play Store URL, app ID) from the Firebase API. Results are cached in-memory for 5 minutes to minimize latency on subsequent clicks.

4

Records the click asynchronously

The click data is sent to POST /v1/click using Cloudflare's waitUntil() API. This means the click is recorded without blocking the redirect -- the user is not kept waiting.

5

Sets the af_click cookie

A first-party cookie named af_click is set with the click ID and a 7-day TTL. On iOS, this cookie can later be recovered by the SDK via SFSafariViewController for deterministic attribution.

6

Returns a 302 redirect

The worker responds with an HTTP 302 redirect to the appropriate store URL, with platform-specific parameters appended (see below).


Platform-specific redirects

The worker detects the user's platform from the User-Agent header and tailors the redirect URL accordingly.

iOS

iOS users are redirected to the App Store URL with a campaign token appended:

iOS redirect example
https://apps.apple.com/app/your-app/id123456789?ct=af_Ab3xK9

The ct (campaign token) parameter is prefixed with af_ followed by the link code. This token appears in App Store Connect analytics but is not used for attribution by the SDK -- it serves as a secondary data point for your own reporting.

Android

Android users are redirected to the Play Store URL with a referrer parameter. This is the key to deterministic attribution on Android:

Android redirect example
https://play.google.com/store/apps/details?id=com.example.app&referrer=utm_source%3Dappfiliate%26af_click_id%3Dlq2x4m_a1b2c3d4%26af_link_id%3DAb3xK9

The referrer string (URL-decoded) contains:

Decoded referrer string
utm_source=appfiliate&af_click_id=lq2x4m_a1b2c3d4&af_link_id=Ab3xK9
ParameterPurpose
utm_sourceIdentifies the traffic source as Appfiliate
af_click_idThe unique click ID generated at click time -- used for deterministic matching
af_link_idThe link code, identifying which creator link was clicked

Desktop

If the user is on a desktop browser (neither iOS nor Android detected), the worker falls back in this order:

  1. App Store URL (if configured for the link)
  2. Play Store URL (if configured)
  3. appfiliate.io as a last resort

Future: smart routing

A single link that automatically routes iOS users to the App Store and Android users to the Play Store is on the roadmap. Today, each link is configured with both store URLs and the worker handles the routing at click time.

Creating links

Tracking links are created in the Appfiliate dashboard at app.appfiliate.io. When you add a creator to your affiliate program, they get access to their own dashboard where they can generate links for each platform they promote on.

Each link stores the following configuration:

  • Short code -- the 6-character alphanumeric identifier
  • iOS destination -- the App Store URL for your app
  • Android destination -- the Play Store URL for your app
  • App ID -- associates the link with your app for analytics
  • Creator ID -- the creator who owns this link, used for revenue attribution

Performance and caching

The Cloudflare Worker uses an in-memory cache for link lookups with a 5-minute TTL. This means the first click on a new link incurs a round trip to the Firebase API, but subsequent clicks (within the same worker instance) are served from cache. The click recording itself is non-blocking thanks to waitUntil(), so the user experiences only the redirect latency.

The response includes Cache-Control: no-cache, no-store to ensure each click is individually tracked and not served from a browser or CDN cache.