- Enable JavaScript Bridge commands (which are only available inside the app)
- Customize your UI and UX (for example, hiding a website nav bar in favor of a native navigation menu, or hiding a footer to create a cleaner app interface)
- Track analytics separately for app vs. browser sessions
- Restrict which pages or features are accessible within the app
Detection strategies
Strategy 1: Detect the custom user agent
Every HTTP request made by your Median app appends a custom string to the device’s default user agent. This is the most common detection method and works on both the frontend and backend.Default user-agent strings
You can change this string in the Web Overrides tab. See Custom user agent for details, and confirm the configured user agent using the device info function in your live app.
Detecting the user agent: frontend (JavaScript)
Use
navigator.userAgent to check for the median string on the client side.
User-Agent header on the server to serve different content or responses based on context.
median string in the User-Agent HTTP header.
JavaScript helper functions
We recommend creating helper functions to simplify complex integrations and to reduce the code that needs to be added throughout your web environment. In the examples below, you calllogAnalyticsEvent() and the event would be transmitted as either a web analytics event or app analytics event by way of the helper function.
Analytics using the Google Firebase Analytics plugin for native app analytics:
Strategy 2: Set custom HTTP headers
Instead of (or in addition to) user-agent detection, you can configure your app to send a custom HTTP header with every request. This can be a cleaner signal than parsing the user-agent string, especially on the backend. Configure custom headers in App Studio under Web Overrides → Custom Headers.
Web Overrides → Custom Headers
X-App-Platform: median-ios header on the iOS app, then reading it server-side:
Strategy 3: Use a dedicated app URL
The simplest approach is to serve a completely separate version of your site at a dedicated subdomain configured as your app’s URL:https://app.yoursite.com
Because only your Median app points to this URL, any request to it is by definition from the app. No user-agent parsing or header inspection is required.
This strategy works well when the app and browser experiences differ significantly. It is recommended when the app version omits marketing pages, sign-up flows, or navigation elements that only make sense in a browser context.
Choosing a strategy
For most projects, user-agent detection in JavaScript is the quickest starting point. Add a helper function early so detection logic stays centralized as your codebase grows.