Mobile App Analytics Testing | Blue Frog Docs

Mobile App Analytics Testing

How to test and validate analytics implementations in iOS and Android apps

Mobile App Analytics Testing

What This Means

Mobile app analytics testing is the process of verifying that tracking events in iOS and Android applications fire correctly and send accurate data. Unlike web analytics, mobile app testing requires different tools, approaches, and considerations:

  • No browser DevTools - Can't inspect network requests easily
  • SDK-based tracking - Analytics integrated via SDKs (Firebase, Segment, etc.)
  • App lifecycle events - Background/foreground transitions affect tracking
  • Platform differences - iOS and Android behave differently
  • Real device testing - Simulators don't capture everything
  • App store restrictions - Privacy requirements affect tracking

Why it matters:

  • Mobile apps can't be "viewed source" like websites
  • Tracking bugs harder to diagnose without proper tools
  • App store rejection if privacy not handled correctly
  • User sessions span multiple app opens/closes
  • Attribution tracking more complex than web

Common challenges:

  • Events not firing in production but work in debug
  • Can't see real-time events without debug mode
  • Simulator behavior differs from real devices
  • Test data polluting production analytics
  • Attribution tracking not connecting app installs to campaigns

How to Diagnose

Most powerful tool for Firebase Analytics / GA4 for Firebase.

Setup for iOS:

  1. Enable debug mode on device/simulator

    # Xcode: Edit Scheme
    # Product → Scheme → Edit Scheme
    # Run → Arguments
    # Add: -FIRDebugEnabled
    
    # Or for release builds, run in Terminal:
    adb shell setprop debug.firebase.analytics.app PACKAGE_NAME
    
  2. Configure in Xcode

    // In scheme arguments, add:
    -FIRDebugEnabled
    
    // To disable verbose logging:
    -FIRDebugDisabled
    
  3. View in DebugView

    • Open Firebase Console
    • Go to Analytics → DebugView
    • Run your app
    • Events appear in real-time

Setup for Android:

  1. Enable debug mode on device

    # Connect device via USB debugging
    # Enable debug mode:
    adb shell setprop debug.firebase.analytics.app YOUR_PACKAGE_NAME
    
    # Example:
    adb shell setprop debug.firebase.analytics.app com.yourcompany.yourapp
    
    # Disable debug mode:
    adb shell setprop debug.firebase.analytics.app .none.
    
  2. View in DebugView

    • Open Firebase Console
    • Analytics → DebugView
    • Run your app
    • Perform actions
    • See events in real-time

What to check in DebugView:

// ✅ Events firing when expected
// ✅ Event names correct
// ✅ All parameters present and correct
// ✅ User properties set
// ✅ Screen names tracking

// ❌ Events not appearing
// ❌ Parameters missing or "null"
// ❌ Wrong event names
// ❌ Events firing multiple times

Method 2: iOS Simulator / Android Emulator Testing

When to use: Quick testing during development.

iOS Simulator (Xcode):

  1. Run app in simulator

    # In Xcode:
    # Select simulator (e.g., iPhone 15)
    # Click Run (Cmd+R)
    
  2. Check Xcode console logs

    // Add logging to your analytics calls:
    Analytics.logEvent("add_to_cart", parameters: [
      "item_name": "Blue T-Shirt",
      "price": 29.99
    ])
    
    print("Analytics: Logged add_to_cart event")
    
    // Check Xcode console for output
    
  3. Enable Firebase debug logging

    // Add to scheme arguments: -FIRAnalyticsDebugEnabled
    // See verbose Firebase logs in console
    

Android Emulator (Android Studio):

  1. Run app in emulator

    # In Android Studio:
    # Select emulator device
    # Click Run
    
  2. Check Logcat

    // Filter Logcat by "Analytics" or "Firebase"
    // Look for event logging messages
    
    // Add custom logging:
    firebaseAnalytics.logEvent("add_to_cart") {
      param("item_name", "Blue T-Shirt")
      param("price", 29.99)
    }
    
    Log.d("Analytics", "Logged add_to_cart event")
    

Limitations:

  • Simulators/emulators don't perfectly match real devices
  • Some device features don't work (GPS, camera, etc.)
  • Performance characteristics differ
  • Push notifications may not work properly

Method 3: Real Device Testing

When to use: Final validation before release, troubleshooting device-specific issues.

iOS Device Testing:

  1. Connect iPhone/iPad via USB

    • Open Xcode
    • Connect device
    • Select device as target
    • Enable debug mode in scheme
  2. Install and run

    # Xcode: Product → Run (Cmd+R)
    # App installs and runs on device
    
  3. Enable DebugView

    # Debug mode enabled via Xcode scheme
    # Events appear in Firebase DebugView
    # Monitor in real-time
    

Android Device Testing:

  1. Enable USB debugging on device

    # Settings → About Phone
    # Tap "Build Number" 7 times
    # Settings → Developer Options
    # Enable "USB Debugging"
    
  2. Connect device and enable debug mode

    # Connect via USB
    adb devices  # Verify device detected
    
    # Enable debug mode:
    adb shell setprop debug.firebase.analytics.app YOUR_PACKAGE_NAME
    
  3. Run app and monitor

    • Android Studio: Run
    • Firebase Console: DebugView
    • Watch events in real-time

Why real device testing matters:

  • Catches iOS version-specific bugs
  • Tests actual network conditions
  • Verifies app store builds
  • Tests device-specific features (Face ID, etc.)

Method 4: Network Traffic Inspection (Charles Proxy)

When to use: Debugging tracking requests at network level.

Setup:

  1. Install Charles Proxy

    • Download from charlesproxy.com
    • Install on computer
  2. Configure iOS device

    # Settings → Wi-Fi
    # Tap (i) next to network
    # Configure Proxy → Manual
    # Server: Your computer's IP
    # Port: 8888
    
    # Install Charles SSL certificate:
    # Safari → chls.pro/ssl
    # Settings → Profile Downloaded → Install
    # Settings → General → About → Certificate Trust Settings
    # Enable Charles Proxy certificate
    
  3. Configure Android device

    # Settings → Wi-Fi
    # Long press network → Modify Network
    # Advanced → Proxy → Manual
    # Hostname: Your computer's IP
    # Port: 8888
    
    # Install certificate:
    # Charles → Help → SSL Proxying → Install on Mobile Device
    # Follow instructions
    
  4. Inspect traffic

    • Run app on device
    • Watch Charles for requests
    • Look for analytics endpoints:
      • Firebase: google-analytics.com
      • Segment: api.segment.io
      • Amplitude: api.amplitude.com

What to check:

// In Charles Proxy:
// - Analytics requests appearing?
// - Request payloads correct?
// - Response codes (200 OK)?
// - Event parameters in payload?
// - No errors or failures?

Method 5: Production Monitoring

When to use: Ongoing monitoring after app release.

Setup in Firebase/GA4:

  1. Monitor event counts

    • Firebase Console → Analytics → Events
    • Check daily event volumes
    • Watch for drops or spikes
  2. Set up alerts

    // In Firebase Console:
    // Analytics → Events
    // Create custom event → Set thresholds
    // Alert if event count drops below expected
    
  3. Review user properties

    • Check if user properties being set
    • Verify values are correct
    • Look for "not set" values

Check for anomalies:

// Red flags:
// - Critical events suddenly stop
// - Event counts drop significantly
// - New app version shows no events
// - Purchase events at 0 (but sales occurring)

General Fixes

Fix 1: Verify SDK Initialization

Problem: Analytics SDK not initialized, no events fire.

Diagnosis:

  • No events appear in DebugView
  • Console shows no Firebase initialization
  • App crashes or errors related to analytics

iOS Fix:

// AppDelegate.swift or App.swift
import Firebase
import FirebaseAnalytics

@main
struct YourApp: App {
    init() {
        // Initialize Firebase
        FirebaseApp.configure()

        // Enable analytics collection
        Analytics.setAnalyticsCollectionEnabled(true)

        print("Firebase initialized successfully")
    }
}

// Verify initialization:
// Check Xcode console for:
// "Firebase initialized successfully"
// "[Firebase/Analytics][I-ACS023007] Firebase Analytics v..."

Android Fix:

// MainActivity.kt or Application class
import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.analytics.ktx.analytics
import com.google.firebase.ktx.Firebase

class MainActivity : AppCompatActivity() {
    private lateinit var firebaseAnalytics: FirebaseAnalytics

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        // Initialize Firebase Analytics
        firebaseAnalytics = Firebase.analytics

        // Enable analytics
        firebaseAnalytics.setAnalyticsCollectionEnabled(true)

        Log.d("Analytics", "Firebase Analytics initialized")
    }
}

// Check Logcat for:
// "Firebase Analytics initialized"

Common mistakes:

// ❌ WRONG: Not calling configure()
// Analytics.logEvent(...)  // Crashes!

// ✅ CORRECT: Initialize first
FirebaseApp.configure()
Analytics.logEvent(...)

Fix 2: Enable Analytics Collection

Problem: SDK initialized but analytics disabled.

Diagnosis:

  • SDK initialized successfully
  • No events in DebugView
  • No errors in console

iOS Fix:

// Explicitly enable analytics
Analytics.setAnalyticsCollectionEnabled(true)

// Check Info.plist - make sure analytics not disabled:
// FIREBASE_ANALYTICS_COLLECTION_ENABLED = YES

// Or remove this key to default to enabled

Android Fix:

// Explicitly enable
firebaseAnalytics.setAnalyticsCollectionEnabled(true)

// Check AndroidManifest.xml:
<meta-data
    android:name="firebase_analytics_collection_enabled"
    android:value="true" />

// Or remove to default to enabled

Check user privacy settings:

// iOS: Respect App Tracking Transparency
import AppTrackingTransparency

if #available(iOS 14, *) {
    ATTrackingManager.requestTrackingAuthorization { status in
        if status == .authorized {
            Analytics.setAnalyticsCollectionEnabled(true)
        }
    }
}

Fix 3: Correct Event Logging Syntax

Problem: Events not logging due to syntax errors.

iOS - Correct syntax:

import FirebaseAnalytics

// Basic event
Analytics.logEvent("add_to_cart", parameters: nil)

// Event with parameters
Analytics.logEvent("add_to_cart", parameters: [
    "item_id": "SKU123",
    "item_name": "Blue T-Shirt",
    "price": 29.99,
    "quantity": 1
])

// Use recommended event names
Analytics.logEvent(AnalyticsEventAddToCart, parameters: [
    AnalyticsParameterItemID: "SKU123",
    AnalyticsParameterItemName: "Blue T-Shirt",
    AnalyticsParameterPrice: 29.99
])

// ❌ WRONG: Invalid parameter types
Analytics.logEvent("add_to_cart", parameters: [
    "item": someObject  // Must be String, Int, or Double
])

// ✅ CORRECT: Convert to string
Analytics.logEvent("add_to_cart", parameters: [
    "item": someObject.description
])

Android - Correct syntax:

import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.analytics.ktx.analytics
import com.google.firebase.analytics.ktx.logEvent
import com.google.firebase.ktx.Firebase

// Basic event
firebaseAnalytics.logEvent("add_to_cart", null)

// Event with parameters (Kotlin DSL)
Firebase.analytics.logEvent(FirebaseAnalytics.Event.ADD_TO_CART) {
    param(FirebaseAnalytics.Param.ITEM_ID, "SKU123")
    param(FirebaseAnalytics.Param.ITEM_NAME, "Blue T-Shirt")
    param(FirebaseAnalytics.Param.PRICE, 29.99)
    param(FirebaseAnalytics.Param.QUANTITY, 1)
}

// Or using Bundle (Java style)
val bundle = Bundle().apply {
    putString(FirebaseAnalytics.Param.ITEM_ID, "SKU123")
    putString(FirebaseAnalytics.Param.ITEM_NAME, "Blue T-Shirt")
    putDouble(FirebaseAnalytics.Param.PRICE, 29.99)
    putInt(FirebaseAnalytics.Param.QUANTITY, 1)
}
firebaseAnalytics.logEvent(FirebaseAnalytics.Event.ADD_TO_CART, bundle)

Fix 4: Debug Mode Not Working

Problem: DebugView shows no events even with debug mode enabled.

iOS Troubleshooting:

// 1. Verify debug flag in scheme
// Xcode → Product → Scheme → Edit Scheme
// Run → Arguments
// Arguments Passed On Launch: -FIRDebugEnabled

// 2. Check console for debug message:
// Should see: "[Firebase/Analytics][I-ACS023007] Debug mode is on"

// 3. Rebuild app completely
// Product → Clean Build Folder (Shift+Cmd+K)
// Product → Build (Cmd+B)
// Product → Run (Cmd+R)

// 4. Verify Google-Services-Info.plist is correct
// Check BUNDLE_ID matches your app
// Check REVERSED_CLIENT_ID is correct

Android Troubleshooting:

# 1. Verify device is connected
adb devices
# Should show device ID

# 2. Enable debug mode again
adb shell setprop debug.firebase.analytics.app YOUR_PACKAGE_NAME

# 3. Verify debug mode enabled
adb shell getprop debug.firebase.analytics.app
# Should return YOUR_PACKAGE_NAME

# 4. Check Logcat for confirmation
# Filter: "FirebaseAnalytics"
# Look for: "Debug-level message logging enabled"

# 5. Force stop and restart app
adb shell am force-stop YOUR_PACKAGE_NAME
# Then launch app again

# 6. Verify google-services.json is correct
# Check package_name matches your app

Fix 5: Events Work in Debug but Not Production

Problem: Events appear in DebugView but not in production reports.

Common causes:

  1. Data processing delay

    // GA4/Firebase takes time to process events:
    // - DebugView: Real-time (seconds)
    // - Realtime report: 30 seconds to few minutes
    // - Standard reports: 24-48 hours
    
    // Solution: Wait 24 hours before investigating
    
  2. Analytics collection disabled in production

    // iOS: Check for conditional logic
    #if DEBUG
        Analytics.setAnalyticsCollectionEnabled(true)
    #else
        Analytics.setAnalyticsCollectionEnabled(false)  // ❌ Wrong!
    #endif
    
    // ✅ Fix: Enable for all builds
    Analytics.setAnalyticsCollectionEnabled(true)
    
  3. App Distribution platform interfering

    // TestFlight, Firebase App Distribution may have differences
    
    // Check if production app properly initialized:
    // Enable verbose logging temporarily in production:
    Analytics.setAnalyticsCollectionEnabled(true)
    
    // Check App Store build includes Firebase SDK
    // Verify google-services files in production bundle
    

Fix 6: Separate Test Data from Production

Goal: Keep test events out of production analytics.

Method 1: Separate Firebase Projects

// Development Firebase Project: your-app-dev
// Production Firebase Project: your-app-prod

// iOS: Use different GoogleService-Info.plist per configuration
// Xcode: Target → Build Phases → Copy Bundle Resources
// Add condition based on configuration

#if DEBUG
    let plistPath = Bundle.main.path(forResource: "GoogleService-Info-Dev", ofType: "plist")
#else
    let plistPath = Bundle.main.path(forResource: "GoogleService-Info-Prod", ofType: "plist")
#endif

// Android: Use different google-services.json per build variant
// app/build.gradle:
productFlavors {
    dev {
        // Uses google-services.json in app/src/dev/
    }
    prod {
        // Uses google-services.json in app/src/prod/
    }
}

Method 2: User Properties for Environment Tagging

// iOS:
#if DEBUG
    Analytics.setUserProperty("development", forName: "environment")
#else
    Analytics.setUserProperty("production", forName: "environment")
#endif

// Android:
firebaseAnalytics.setUserProperty("environment",
    if (BuildConfig.DEBUG) "development" else "production"
)

// Then filter in Firebase Console by environment

Platform-Specific Notes

Platform Key Considerations
iOS (Native) Use -FIRDebugEnabled flag, test on real device, verify App Store privacy labels
Android (Native) Use adb shell setprop for debug mode, test with USB debugging enabled
React Native Use same Firebase setup, debug via React Native Debugger and DebugView
Flutter Use firebase_analytics package, configure platform-specific debug modes

Testing Checklist

Pre-Release Testing

// □ Debug mode working in development
// □ All critical events firing correctly
// □ Event parameters accurate
// □ User properties set correctly
// □ Screen tracking working
// □ E-commerce events complete
// □ Attribution tracking configured
// □ Tested on real iOS device
// □ Tested on real Android device
// □ Tested on multiple OS versions
// □ Test data not in production analytics
// □ Production Firebase project configured
// □ Privacy/consent handling implemented
// □ App Store privacy labels accurate

Post-Release Monitoring

// After app release:
// □ Verify events appearing in production analytics
// □ Check event volumes match expectations
// □ Monitor for event drops or spikes
// □ Verify conversion tracking working
// □ Check user retention data
// □ Review crash reports for analytics-related issues

Common Mistakes to Avoid

  1. Not testing on real devices - Simulators don't catch everything
  2. Forgetting to disable debug mode - Production builds shouldn't have debug enabled
  3. Not separating test/production data - Pollutes production analytics
  4. Ignoring data processing delays - Wait 24-48 hours for standard reports
  5. Not checking privacy compliance - App Store may reject
  6. Hardcoding production keys in debug builds - Use build configurations
  7. Not monitoring after release - Issues may only appear in production

Further Reading

// SYS.FOOTER