# Click Handling & Redirect Flow

When a user opens a Detour link, the platform determines which app the link
belongs to, records the click, and redirects the user. This page describes that
flow and what you can configure.

---

## High-level flow

1. The user opens a Detour link in a browser.

   The link has the form `https://<host>/<hash>/...`.

2. Detour records the click.

   Either Detour collects the device fingerprint right away, or the user sees the
   iOS copy-link page and decides whether to copy the link to the clipboard. You
   choose which one in the iOS configuration in the Dashboard.

   With `#detour_open_app=true` in the Meta in-app browsers that support it,
   Detour tries to open the installed app first and does not record the click
   on page load. Facebook gets this without the flag. See
   [Links in Social Apps](https://detour.swmansion.com/docs/platform/architecture/social-app-links).

3. If **App Preview** is on, the user sees the preview page.

   The user taps to continue instead of being redirected right away.

4. Detour redirects the user.

   Mobile users go to the App Store or Google Play. Desktop users go to the
   fallback URL.

5. The user installs and opens the app.

   On first open, the SDK calls the match endpoint. If the click is matched, the
   SDK receives the link data.

You can replace each page in this flow with your own HTML. See
[Custom HTML Redirects](https://detour.swmansion.com/docs/platform/advanced/custom-html-redirects).

## Click handling

Detour recognizes deferred links on platform hosts such as `*.godetour.link`, as well as on any configured custom domain. It looks up the app configuration attached to the link and redirects the user according to device OS and runtime context.

Only the base segment, the platform-generated hash, is canonical for that lookup. Anything you append to it is free-form:

- extra path segments
- URL search parameters

Neither affects deferred-link resolution, and both are delivered to your app in the returned link data. One app can therefore serve many campaign and content routes under a single base hash.

## Reserved link parameters

Most search parameters on a link are free-form and are passed to your app.
A few names are read by the platform itself:

| Parameter                                                             | Read by                                           | Effect                                                                                        |
| --------------------------------------------------------------------- | ------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| `ppid`                                                                | the iOS store redirect                            | Sends the visitor to a specific App Store **custom product page** instead of the default one. |
| `pt`, `ct`, `mt`                                                      | the iOS store redirect                            | Forwarded to the App Store URL for campaign reports in App Store Connect.                     |
| `utm_source`, `utm_medium`, `utm_campaign`, `utm_term`, `utm_content` | the Android store redirect                        | Forwarded inside the `referrer` of the Play Store URL for campaign reports in Play Console.   |
| `dtb`                                                                 | [Smart Banners](https://detour.swmansion.com/docs/platform/advanced/smart-banners) | Identifies which banner a tap came from, for banner statistics.                               |

### App Store custom product pages (`ppid`)

Append `?ppid=<product-page-id>` to a link and iOS installs from it open that
custom product page, with different screenshots and promotional text per campaign,
without a separate app or a separate link base:

```
https://acme-corp.godetour.link/x9y8z7/summer?ppid=1a2b3c4d-5e6f-7890-abcd-ef1234567890
```

The id is the UUID App Store Connect assigns to the product page. Constraints:

- **iOS only.** Play Store custom store listings are selected by a different
  mechanism, so the Android URL never carries it.
- **A malformed id is dropped**, not passed through. The App Store would silently
  serve the default page for an invalid id, which looks like a working campaign
  showing the wrong screenshots.
- It is an ordinary query parameter, so it also appears in the per-parameter
  click breakdown in [Analytics](https://detour.swmansion.com/docs/platform/fundamentals/analytics).

### Store campaign parameters

Only App Store Connect and Play Console report what happens on the store page,
such as product page views and downloads. To see those numbers per campaign,
add the campaign parameters of App Store Connect and Google Play to the link:

```txt
https://your-org.godetour.link/<app_hash>/summer?pt=118032&ct=summer-email&utm_source=newsletter&utm_campaign=summer-email
```

- **iOS** — Detour forwards `pt`, `ct`, and `mt` to the App Store URL.

  Copy the values from an App Store Connect campaign link.
- **Android** — Detour forwards the UTM keys inside the `referrer` parameter of
  the Play Store URL.

  Add them to the link as ordinary parameters, not inside a `referrer` of your
  own. Detour puts them in `referrer` next to its own `click_id`.
- Each store URL carries only its own keys, and never a key with an empty value.
- On a short link, save the parameters with the short link or add them to its
  URL. A parameter in the URL replaces a saved one with the same name.
- Your app receives these parameters in the link data, and they appear in the
  per-parameter click breakdown in [Analytics](https://detour.swmansion.com/docs/platform/fundamentals/analytics).

Detour counts every click on the link, while App Store Connect and Play Console
count store page views and downloads by their own rules. Compare campaigns by
their ratios, not by the absolute counts.

## Runtime safeguards

Detour includes safeguards against false attribution and redirect loops:

- Automated and low-quality traffic is filtered out from attribution.
- Repeated redirect attempts are guarded to avoid redirect loops.
- If the redirect target cannot be resolved, the user sees a fallback failure view.

### Return to the web destination

After a store redirect, Detour detects the visitor returning to the page, which
happens when the store was dismissed, the app was not installed, or the browser
restored the page from its back/forward cache. Instead of leaving the visitor on
a redirect page that does nothing, Detour sends them to the web destination.

### In-app browsers on iOS

Instagram, Threads, Facebook, and TikTok in-app browsers on iOS stopped loading
App Store URLs, so a link that redirects to the store stops there. The Meta
browsers end on a blank page with no error. TikTok shows an error toast.

For those browsers, and only for App Store destinations, Detour changes what it
does:

- **Instagram and Threads** — Detour opens the App Store URL outside the
  webview, through another browser or the App Store app. If the hand-off does
  not go through, the visitor stays on the page with a button to continue
  manually.
- **Facebook** — Detour first tries to open the installed app, through Safari
  for a link in a post or an ad, and through an **Open app** button for a link
  in a bio. Without the app, the visitor then reaches the App Store.
- **Messenger** — the automatic redirect does not open the App Store, so Detour
  shows the **App Store** button. A tap opens the App Store without a hand-off.
- **TikTok** — no hand-off works, so Detour does not attempt one and does not
  show **App Preview** or the iOS copy-link page. The page tells the visitor to
  open it in their own browser from the `•••` menu.

For what this costs in attribution, see
[In-app browsers block the App Store](https://detour.swmansion.com/docs/platform/architecture/architecture-limitations#in-app-browsers-block-the-app-store).
For what each app does, and for opening the installed app from these browsers,
see [Links in Social Apps](https://detour.swmansion.com/docs/platform/architecture/social-app-links).

Nothing else changes:

- Safari, Chrome, desktop, and every Android in-app browser keep the instant
  redirect. The exceptions are a link with the `#detour_open_app=true` flag in a
  Meta in-app browser and every link in Facebook on Android. See
  [Links in Social Apps](https://detour.swmansion.com/docs/platform/architecture/social-app-links).
- Android in-app browsers open Play Store URLs, so they need no hand-off. A
  hand-off would also drop the install referrer, which carries `click_id`.

For host-specific behavior and `/.well-known` implications on custom domains, see [Custom Domain](https://detour.swmansion.com/docs/platform/advanced/custom-domain).

## Forwarding query parameters

An app has one desktop redirect URL, shared by all of its deferred links. The search parameters on the clicked link can still be forwarded to that URL. Pick a strategy in **Link settings**:

- **Pass all parameters** — every search param on the deferred link is forwarded to the desktop fallback.
- **Pass specific parameters** — only the params you name are passed.
- **Don't pass parameters** — the fallback URL is used as-is.

For matching details after first app open, see [Matching](https://detour.swmansion.com/docs/platform/architecture/matching). For platform-level setup context, see [Dashboard Walkthrough](https://detour.swmansion.com/docs/platform/fundamentals/dashboard).