> For the complete documentation index, see [llms.txt](https://help.twinr.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.twinr.dev/native-integrations/overview-1/custom-user-agent.md).

# Custom User Agent

Tell your website when a visit comes from the app.

Every request a browser makes carries a **user agent** — a line of text identifying what is asking. Custom User Agent adds your own text to the one your app sends, so your website can tell an app visit from an ordinary mobile browser visit.

That matters whenever your site should behave differently inside the app: hiding a "Download our app" banner, skipping a cookie notice you have already handled, or routing app traffic differently in your analytics.

## Turn it on

Open **Native Features → Custom User Agent** and switch on **Enable Custom User Agent**.

<figure><img src="https://3731994945-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MlBy5z08zL1UoCwNqmg%2Fuploads%2Fgit-blob-f09a0019f0d0e0f714aea9ec62b3d54717a72e81%2Fnf-custom-user-agent.png?alt=media" alt="The Custom User Agent screen with separate Android and iOS fields"><figcaption></figcaption></figure>

| Setting                                   | What it does                                                     |
| ----------------------------------------- | ---------------------------------------------------------------- |
| **Android User Agent**                    | Text sent with every request from the Android app.               |
| **Attach with actual android user agent** | Append your text to the real user agent instead of replacing it. |
| **iOS User Agent**                        | Text sent with every request from the iOS app.                   |
| **Attach with actual iOS user agent**     | Append your text to the real user agent instead of replacing it. |

Click **Save as draft**.

{% hint style="warning" %}
**Leave the "Attach with actual" toggles on.** With them on, your text is added to the real user agent, so your website still knows the browser engine, version and platform. With them off, your text *replaces* the lot — and anything on your site that depends on knowing the real browser, including many analytics tools and some payment providers, will see a user agent it does not recognise.
{% endhint %}

## Choosing your text

Something short and distinctive you can match on — `mobile-app`, or your brand plus the word app. Avoid anything that looks like a real browser name, or you will confuse the tools trying to parse it.

You can use the same value on both platforms, or different ones if you want to tell Android and iOS traffic apart.

## Detecting it on your site

Check whether your string appears in the user agent. In JavaScript:

```javascript
if (navigator.userAgent.includes('mobile-app')) {
  // hide the app-install banner
}
```

Server-side, read the `User-Agent` request header and look for the same string.

{% hint style="info" %}
If you only need to hide a banner or tweak a layout inside the app, [Hide Elements](/screen-customization/hide-elements.md) and [Custom CSS](/screen-customization/apply-custom-css.md) do that without touching your website's code.
{% endhint %}

## Check it

Open your app in Twinr Preview and load a page that reports the user agent, or watch your server logs. Your string should appear on every request from the app, and on none from a mobile browser.
