# Links in Social Apps

Instagram, Threads, Facebook, Messenger, and TikTok open links in their own
in-app browser. There, a link does not always open your installed app or the
store. This page describes what Detour does in each of these apps and how the
`#detour_open_app=true` flag opens the installed app.

## The open-app flag

In some in-app browsers, a Universal Link or an App Link does not open your
installed app, and the visitor goes to the store instead. Add
`#detour_open_app=true` to the end of a link to make Detour try to open the
installed app first:

```txt
https://your-org.godetour.link/<app_hash>/promo#detour_open_app=true
```

:::note[Instagram changes the link in a bio]
Instagram on iOS saves the flag in a bio as `%23detour_open_app%3Dtrue` and
adds its own parameters after it. Detour restores the flag, so the link works
as you pasted it.
:::

The flag works in these apps:

- **Instagram and Threads** — on iOS and Android.
- **Messenger** — on Android.

In every other app and browser, Detour ignores the flag, so you can use the same
link everywhere. Facebook, and Messenger on iOS, open the installed app without
the flag.

Your app does not receive the flag in the link data.

In the apps where the flag works, a link with it shows the Detour redirect page
with a store button instead of **App Preview**, the iOS copy-link page, or a
[custom HTML](https://detour.swmansion.com/docs/platform/advanced/custom-html-redirects) page. A visitor without
your app either taps the store button there or goes to the browser, which shows
these pages as you configured them. The sections below say which one each app
does.

## Instagram and Threads

Instagram and Threads behave the same.

- **iOS, app installed** — without the flag, the visitor goes to the App
  Store.

  With the flag, the app opens the link outside its in-app browser, and iOS
  opens your app.

- **iOS, app not installed** — Detour opens the App Store outside the app.

  Instagram and Threads do not open App Store links themselves. Detour opens
  the App Store from the redirect page, from the iOS copy-link page, and from
  **Continue** on **App Preview**. With the flag, the link opens in the browser,
  which opens the App Store.

- **Android, app installed** — without the flag, Detour redirects to Google
  Play.

  With the flag, the app asks the visitor to leave it, then your app opens.

- **Android, app not installed** — Detour redirects to Google Play.

  With the flag, the visitor stays on the page and taps **Google Play**.

:::caution[Meta can change this behavior]
Meta does not document how its apps open other apps, and can change it without
notice. If Detour cannot open the App Store, the visitor stays on the page with
an **App Store** button.
:::

## Facebook

Facebook needs no flag. Detour tries to open your app from every link in
Facebook. Facebook removes the flag from a link, so a link with the flag works
there too.

- **iOS, link in a post or an ad** — Facebook asks the visitor to open the
  link in Safari.

  Safari opens your app, or the App Store when the app is not installed. If
  the visitor declines, the page shows an **App Store** button.

- **iOS, link in a profile bio** — the page shows an **Open app** button with
  this line:

  ```txt
  Tap the button below to open the app.
  ```

  A tap opens your app, or the App Store when the app is not installed.

- **Android** — Facebook asks the visitor to leave the app.

  Then your app opens. When the app is not installed, the link opens in the
  default browser, which redirects to Google Play. If the visitor declines, the
  page shows a **Google Play** button.

:::note[Facebook lowercases a link in a bio]
Facebook saves a link in a profile bio in lowercase. Detour restores the case of
the app hash, so the link opens. The rest of the path and the parameters reach
your app in lowercase, so match them without regard to case.
:::

Facebook on iOS loads the link page even when your app is installed. With
**App Preview** or the iOS copy-link page turned on, the visitor sees that page
first. A tap on **Continue** or on a copy-link button opens your app, or the App
Store when the app is not installed.

Facebook on Android does not show **App Preview** or a
[custom HTML](https://detour.swmansion.com/docs/platform/advanced/custom-html-redirects) page. The visitor sees
the Detour redirect page with a **Google Play** button.

## Messenger

- **iOS, app installed** — your app opens.
- **iOS, app not installed** — Messenger does not open the App Store on its
  own.

  After a few seconds, the page shows an **App Store** button, and a tap opens
  the App Store.

- **Android, app installed** — without the flag, Detour redirects to Google
  Play.

  With the flag, Messenger asks the visitor to leave the app, then your app
  opens.

- **Android, app not installed** — Detour redirects to Google Play.

  With the flag, the link opens in the default browser, which redirects to
  Google Play.

On iOS, Messenger needs no flag, and a link with the flag works the same.

## TikTok

- **iOS** — TikTok does not open the App Store from a link in a bio.

  After **3 seconds**, the redirect page shows these lines above the
  **App Store** button:

  ```txt
  If the App Store didn't open, this app is blocking it.
  Tap ••• in the top right, then open this page in your browser.
  ```

  The text follows the browser language: `en`, `pl`, `es`, `fr`, `de`, `it`,
  `pt`, `nl`, `ja`, `ko`, or `zh`. Other languages get English.

  From a direct message, the App Store opens.

- **Android** — Detour redirects to Google Play.

TikTok on iOS does not show **App Preview** or the iOS copy-link page. The
visitor sees the redirect page instead, also for a link from a direct message.
In the browser, these pages show as you configured them.

## Behavior by app

The tables below compare the apps for a link that leads to the store. Outside
in-app browsers, a Universal Link or an App Link opens your installed app, and a
visitor without the app goes to the store.

### Your app is installed

| App                  | Default                                                                                                                  | With the flag        |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------ | -------------------- |
| Instagram, Threads   | The app does not open. Detour opens the App Store.                                                                       | The app opens.       |
| Facebook<sup>1</sup> | From a post or an ad, Facebook asks to open Safari, then the app opens. From a bio, a tap on **Open app** opens the app. | Same as the default. |
| Messenger            | The app opens.                                                                                                           | Same as the default. |

<div class="table-footnote">
<sup>1</sup> With **App Preview** or the iOS copy-link page, the visitor taps **Continue** or a copy-link button instead. See [Facebook](#facebook).
</div>

| App                           | Default                                                 | With the flag                                  |
| ----------------------------- | ------------------------------------------------------- | ---------------------------------------------- |
| Facebook                      | Facebook asks to leave the app, then the app opens.     | Same as the default.                           |
| Instagram, Threads, Messenger | The app does not open. Detour redirects to Google Play. | The app asks to leave it, then your app opens. |

### Your app is not installed

| App                  | Default                                                                                                                                         | With the flag                                             |
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
| Instagram, Threads   | Detour opens the App Store.                                                                                                                     | The link opens in the browser, which opens the App Store. |
| Facebook<sup>1</sup> | From a post or an ad, Facebook asks to open Safari, then the App Store opens. From a bio, a tap on **Open app** opens the App Store.            | Same as the default.                                      |
| Messenger            | A tap on **App Store** opens the App Store.                                                                                                     | Same as the default.                                      |
| TikTok               | From a bio, the App Store does not open, and Detour asks the visitor to open the page in a browser. From a direct message, the App Store opens. | Same as the default.                                      |

<div class="table-footnote">
<sup>1</sup> With **App Preview** or the iOS copy-link page, the visitor taps **Continue** or a copy-link button instead. See [Facebook](#facebook).
</div>

| App                | Default                                                                                               | With the flag                                                          |
| ------------------ | ----------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| Facebook           | Facebook asks to leave the app, then the default browser opens the link and redirects to Google Play. | Same as the default.                                                   |
| Instagram, Threads | Detour redirects to Google Play.                                                                      | A tap on **Google Play** opens the store.                              |
| Messenger          | Detour redirects to Google Play.                                                                      | The link opens in the default browser, which redirects to Google Play. |
| TikTok             | Detour redirects to Google Play.                                                                      | Same as the default.                                                   |

As the tables show, the flag sometimes adds one automatic step in which the
link opens in the browser. In return, a Universal Link or an App Link opens
your app when it is installed.

## App Preview and the iOS copy-link page

**App Preview** and the iOS copy-link page are pages that Detour shows before
the store. You turn them on in
[Redirect page](https://detour.swmansion.com/docs/platform/fundamentals/dashboard#redirect-page). Outside in-app
browsers, they show only when your app is not installed, because a Universal
Link or an App Link opens the installed app first. In the in-app browsers, the
result is:

The page is App Preview or the copy-link page, whichever is on. With both on,
iOS shows the copy-link page.

| App                               | App installed                                   | App not installed                                                                                |
| --------------------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| Outside in-app browsers           | Your app opens. Neither page shows.             | The page shows. Its button opens the App Store.                                                  |
| Instagram, Threads                | The page shows. Its button opens the App Store. | The page shows. Its button opens the App Store.                                                  |
| Instagram, Threads, with the flag | Your app opens. Neither page shows.             | The link opens in the browser, which shows the page.                                             |
| Facebook                          | The page shows. Its button opens your app.      | The page shows. Its button opens the App Store.                                                  |
| Messenger                         | Your app opens. Neither page shows.             | The page shows. Its button opens the App Store.                                                  |
| TikTok                            | Neither page shows.                             | Neither page shows. Detour asks the visitor to open the link in a browser, which shows the page. |

Android has no copy-link page.

| App                               | App installed                                      | App not installed                                                    |
| --------------------------------- | -------------------------------------------------- | -------------------------------------------------------------------- |
| Outside in-app browsers           | Your app opens. App Preview does not show.         | App Preview shows. **Continue** opens Google Play.                   |
| Instagram, Threads, Messenger     | App Preview shows. **Continue** opens Google Play. | App Preview shows. **Continue** opens Google Play.                   |
| Instagram, Threads, with the flag | After a prompt to leave the app, your app opens.   | App Preview does not show. A tap on **Google Play** opens the store. |
| Messenger, with the flag          | After a prompt to leave the app, your app opens.   | The link opens in the default browser, which shows App Preview.      |
| Facebook                          | After a prompt to leave the app, your app opens.   | The link opens in the default browser, which shows App Preview.      |

## Parameters added by social apps

Social apps can add their own parameters to a link. For example, Instagram adds
`utm_*` parameters to a link in a bio, and Facebook adds `fbclid` to a link in a
post or an ad. Detour treats them as ordinary link parameters:

- Your app receives them in the link data.
- They appear in [Analytics](https://detour.swmansion.com/docs/platform/fundamentals/analytics).
- On Android, Detour forwards the `utm_*` parameters to Google Play. It does not
  forward `fbclid`.

The same holds for a short link. Detour adds the parameters in the short link
URL to the parameters saved with the short link. When both have a parameter
with the same name, the value in the URL is used.
See [Store campaign parameters](https://detour.swmansion.com/docs/platform/architecture/click-handling#store-campaign-parameters).

## Related pages

[Click Handling & Redirect Flow](https://detour.swmansion.com/docs/platform/architecture/click-handling/)
  [Limitations & Known Issues](https://detour.swmansion.com/docs/platform/architecture/architecture-limitations/)
  [Universal Links & App Links](https://detour.swmansion.com/docs/platform/fundamentals/universal-app-links/)
  [Custom HTML Redirects](https://detour.swmansion.com/docs/platform/advanced/custom-html-redirects/)