Skip to main content

Deep Linking

Deep linking allows users to navigate directly to specific content within your mobile apps or web applications, creating seamless user experiences across platforms and devices.

What is Deep Linking?

Deep links are URLs that take users directly to specific content within your app, rather than just opening the app’s main screen. They enable:
  • Seamless Navigation: Users can jump directly to relevant content
  • Cross-Platform Experience: Consistent experience across web and mobile
  • Marketing Campaigns: Direct users to specific app content
  • User Retention: Reduce friction in user journeys
Navigation between different apps on the same device:
  • Social Media: Share content from your app to social platforms
  • Payment Apps: Integrate with payment and banking apps
  • Maps & Navigation: Open location-based services
  • Communication: Integrate with messaging and email apps
Redirect web users to specific app content:
  • Marketing Links: Direct users from campaigns to app content
  • Social Sharing: Share app content on social media
  • Email Campaigns: Include deep links in email marketing
  • QR Codes: Physical-to-digital content access
Consistent experience across different platforms:
  • Universal Links: iOS web-to-app navigation
  • App Links: Android web-to-app navigation
  • Fallback Handling: Web alternatives when apps aren’t installed
  • Progressive Web Apps: Web app deep linking

Platform-Specific Implementation

Universal Links provide seamless web-to-app experiences on iOS:

1. App Configuration

Add associated domains to your iOS app:
// In your iOS app's Associated Domains capability
// Add: applinks:yourdomain.com

2. Server Configuration

Host the required JSON file on your server:
// https://yourdomain.com/.well-known/apple-app-site-association
{
  "applinks": {
    "apps": [],
    "details": [
      {
        "appID": "TEAM_ID.BUNDLE_ID",
        "paths": [
          "/products/*",
          "/categories/*",
          "/search?*"
        ]
      }
    ]
  }
}

3. App Delegate Implementation

Handle universal links in your app:
import UIKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    
    func application(_ application: UIApplication, 
                    continue userActivity: NSUserActivity, 
                    restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
        
        if userActivity.activityType == NSUserActivityTypeBrowsingWeb {
            if let url = userActivity.webpageURL {
                // Handle the universal link
                handleUniversalLink(url: url)
                return true
            }
        }
        return false
    }
    
    private func handleUniversalLink(url: URL) {
        // Parse the URL and navigate to appropriate content
        let path = url.path
        let query = url.query
        
        // Navigate based on path and query parameters
        navigateToContent(path: path, query: query)
    }
}
App Links enable direct web-to-app navigation on Android:

1. Manifest Configuration

Configure intent filters in your AndroidManifest.xml:
<activity android:name=".MainActivity">
    <intent-filter android:autoVerify="true">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        
        <!-- Handle your domain -->
        <data android:scheme="https"
               android:host="yourdomain.com"
               android:pathPrefix="/products" />
    </intent-filter>
</activity>

2. Domain Verification

Verify domain ownership through the Android system:
<!-- The android:autoVerify="true" attribute triggers automatic verification -->
<!-- Android will verify your domain and enable app links -->

3. Activity Implementation

Handle app links in your activities:
class MainActivity : AppCompatActivity() {
    
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        
        // Handle incoming app links
        handleIntent(intent)
    }
    
    override fun onNewIntent(intent: Intent?) {
        super.onNewIntent(intent)
        handleIntent(intent)
    }
    
    private fun handleIntent(intent: Intent?) {
        intent?.data?.let { uri ->
            // Parse the URI and navigate to appropriate content
            val path = uri.path
            val query = uri.query
            
            // Navigate based on path and query parameters
            navigateToContent(path, query)
        }
    }
}

URL Patterns

Design consistent deep link structures:
https://yourdomain.com/products/123
https://yourdomain.com/categories/electronics
https://yourdomain.com/search?q=laptop&category=computers
https://yourdomain.com/user/profile/456

Parameter Handling

Handle dynamic content through URL parameters:
// iOS parameter parsing
func parseDeepLink(url: URL) -> DeepLinkData? {
    let components = URLComponents(url: url, resolvingAgainstBaseURL: true)
    
    guard let path = components?.path,
          let queryItems = components?.queryItems else {
        return nil
    }
    
    // Parse path components
    let pathParts = path.components(separatedBy: "/")
    
    // Parse query parameters
    var params: [String: String] = [:]
    for item in queryItems {
        params[item.name] = item.value
    }
    
    return DeepLinkData(path: pathParts, parameters: params)
}
// Android parameter parsing
private fun parseDeepLink(uri: Uri): DeepLinkData? {
    val path = uri.path
    val query = uri.query
    
    // Parse path components
    val pathParts = path?.split("/") ?: emptyList()
    
    // Parse query parameters
    val params = mutableMapOf<String, String>()
    uri.queryParameterNames.forEach { name ->
        uri.getQueryParameter(name)?.let { value ->
            params[name] = value
        }
    }
    
    return DeepLinkData(path = pathParts, parameters = params)
}

Development Testing

Test deep links during development:

iOS Simulator Testing

# Test universal links in iOS Simulator
xcrun simctl openurl booted "https://yourdomain.com/products/123"

Android Emulator Testing

# Test app links in Android Emulator
adb shell am start -W -a android.intent.action.VIEW -d "https://yourdomain.com/products/123" com.yourapp.package

Production Testing

Verify deep links work in production:
  1. Physical Devices: Test on real iOS and Android devices
  2. Different Scenarios: App installed, app not installed
  3. Fallback Handling: Ensure web alternatives work
  4. Cross-Platform: Test iOS to Android and vice versa

Testing Tools

Use these tools to test deep links:
  • Branch.io Tester: Test deep links across platforms
  • Firebase Dynamic Links: Google’s deep linking solution
  • Custom Test Pages: Create test pages for validation
  • Analytics Monitoring: Track deep link performance

Fallback Handling

Web Alternatives

Provide web alternatives when apps aren’t installed:
// Web fallback implementation
function handleDeepLink(url) {
    // Check if app is installed
    if (isAppInstalled()) {
        // Open app with deep link
        openApp(url);
    } else {
        // Redirect to web version
        redirectToWeb(url);
    }
}

function redirectToWeb(url) {
    // Convert deep link to web URL
    const webUrl = convertToWebUrl(url);
    window.location.href = webUrl;
}

Progressive Enhancement

Implement progressive enhancement for better user experience:
  1. Primary: Try to open native app
  2. Secondary: Redirect to web app if available
  3. Fallback: Show app store download page
  4. Final: Display web version of content

Analytics and Tracking

Track deep link effectiveness:
  • Click-through Rates: How many users click deep links
  • Install Attribution: Track app installs from deep links
  • User Engagement: Monitor user behavior after deep link navigation
  • Conversion Tracking: Measure business outcomes

Implementation with Inhouse

Integrate deep link tracking with Inhouse:
// iOS tracking
import InhouseSDK

func trackDeepLink(url: URL) {
    Inhouse.track("deep_link_opened", properties: [
        "url": url.absoluteString,
        "source": "universal_link",
        "timestamp": Date().timeIntervalSince1970
    ])
}
// Android tracking
import com.inhouse.sdk.Inhouse

private fun trackDeepLink(uri: Uri) {
    Inhouse.track("deep_link_opened", mapOf(
        "url" to uri.toString(),
        "source" to "app_link",
        "timestamp" to System.currentTimeMillis()
    ))
}

Best Practices

URL Design

  1. Consistent Structure: Use predictable URL patterns
  2. SEO Friendly: Design URLs for search engines
  3. User Friendly: Make URLs readable and memorable
  4. Scalable: Plan for future content and features

User Experience

  1. Seamless Navigation: Minimize friction in user journeys
  2. Fallback Handling: Always provide alternatives
  3. Loading States: Show appropriate loading indicators
  4. Error Handling: Gracefully handle invalid links

Technical Implementation

  1. Performance: Optimize deep link resolution speed
  2. Security: Validate and sanitize incoming links
  3. Testing: Comprehensive testing across platforms
  4. Monitoring: Track performance and errors

Troubleshooting

Common Issues

  • Check app installation status
  • Verify intent filter configuration
  • Test with different link formats
  • Review app permissions
  • Test web alternatives
  • Verify fallback URL structure
  • Check redirect handling
  • Test cross-platform compatibility

Debugging Tools

Use these tools for debugging:
  • iOS Console: View system logs and errors
  • Android Logcat: Monitor Android system logs
  • Network Inspector: Check HTTP requests and responses
  • Deep Link Validators: Platform-specific validation tools

Next Steps

Domain Management

Configure custom domains for your deep links.

Apps Tracking

Set up comprehensive app tracking and analytics.

API Reference

Integrate deep linking into your workflows.

Settings

Configure deep linking settings and preferences.
Need help with deep linking? Check our API documentation or contact [email protected].