Firebase Analytics enforces a limit of 25 parameters per custom event. This error occurs when your app attempts to log an event with more than the allowed number of parameters, causing the event to be rejected by the Firebase Analytics service.
The "Analytics: Code 5 - Event has more than 25 parameters" error is a Firebase Analytics limitation error that occurs when you try to log a custom event with more than 25 parameters. Firebase Analytics imposes this limit to ensure efficient data processing and storage. Each custom event in Firebase Analytics can have associated parameters (key-value pairs) that provide additional context about the event. While Firebase allows up to 500 different event types and unlimited total events, it restricts the number of parameters per individual event to 25. This limitation exists because: 1. **Performance optimization**: Too many parameters per event can slow down data processing 2. **Storage efficiency**: Firebase needs to optimize how event data is stored and queried 3. **Data quality**: Encourages developers to be selective about what data they track When you exceed this limit, Firebase Analytics rejects the event entirely, which means none of the parameters or the event itself gets logged to your analytics dashboard.
First, identify how many parameters you're sending with your event. Check your event logging code:
// Example Firebase Analytics event with too many parameters
logEvent(analytics, 'purchase', {
item_id: 'SKU_123',
item_name: 'Premium Widget',
item_category: 'Electronics',
price: 99.99,
currency: 'USD',
quantity: 1,
// ... 20+ more parameters
});Count all key-value pairs in your event parameters object. If it exceeds 25, you need to reduce the number.
Combine related parameters into structured strings or use parameter nesting where possible:
// Instead of separate parameters for each user property:
logEvent(analytics, 'user_profile_update', {
user_age: '30',
user_gender: 'male',
user_location: 'New York',
user_occupation: 'developer',
// ... many more
});
// Group into a structured parameter:
logEvent(analytics, 'user_profile_update', {
user_profile: JSON.stringify({
age: '30',
gender: 'male',
location: 'New York',
occupation: 'developer'
// Can include many properties as JSON
}),
update_timestamp: new Date().toISOString()
});Note: You'll need to parse this JSON later when analyzing the data.
If you have logically distinct groups of parameters, consider splitting them into separate events:
// Instead of one event with 30+ parameters:
logEvent(analytics, 'checkout_complete', allParameters);
// Split into logical events:
logEvent(analytics, 'checkout_items', {
item_count: 3,
total_value: 299.97,
// Item-specific parameters (max 25)
});
logEvent(analytics, 'checkout_payment', {
payment_method: 'credit_card',
payment_processor: 'stripe',
// Payment-specific parameters (max 25)
});
logEvent(analytics, 'checkout_shipping', {
shipping_method: 'express',
shipping_address: '123 Main St',
// Shipping-specific parameters (max 25)
});Use a common event parameter like checkout_id to correlate these events later.
Review your event parameters and remove any that aren't essential for analysis:
1. Debug information: Remove debug flags, timestamps (unless critical), and development metadata
2. Redundant data: Avoid logging the same information in multiple parameters
3. Derived values: Calculate values during analysis instead of logging them
4. Temporary data: Remove session-specific or transient data
// Before: 28 parameters including debug info
logEvent(analytics, 'app_launch', {
app_version: '1.2.3',
os_version: '15.4',
device_model: 'iPhone13,4',
debug_mode: true, // Remove this
session_id: 'abc123',
timestamp_ms: 1640995200000, // Firebase adds timestamp automatically
// ... 22 more parameters
});
// After: 20 essential parameters
logEvent(analytics, 'app_launch', {
app_version: '1.2.3',
os_version: '15.4',
device_model: 'iPhone13,4',
session_id: 'abc123',
// ... 16 more essential parameters
});Add validation to prevent exceeding the limit in the future:
function safeLogEvent(analytics, eventName, params) {
const paramCount = Object.keys(params).length;
if (paramCount > 25) {
console.warn(`Event "${eventName}" has ${paramCount} parameters (max 25). Trimming to 25.`);
// Keep only the first 25 parameters
const limitedParams = {};
let count = 0;
for (const [key, value] of Object.entries(params)) {
if (count >= 25) break;
limitedParams[key] = value;
count++;
}
logEvent(analytics, eventName, limitedParams);
return;
}
logEvent(analytics, eventName, params);
}
// Use the safe function
safeLogEvent(analytics, 'custom_event', yourParameters);This ensures you never exceed the limit, though you should still optimize your parameters.
After making changes, test your events to ensure they're being logged correctly:
1. Enable debug mode in Firebase Analytics
2. Check Android Logcat or iOS console for debug messages
3. Verify events appear in the Firebase Console DebugView
4. Monitor for the "Code 5" error - it should no longer appear
// For web: Enable debug mode
import { getAnalytics, setAnalyticsCollectionEnabled } from "firebase/analytics";
const analytics = getAnalytics();
// In development only:
analytics.setDebugModeEnabled?.(true);
// For Android: Add to AndroidManifest.xml
// <meta-data
// android:name="firebase_analytics_collection_deactivated"
// android:value="false" />
// And enable verbose logging in app
// For iOS: Add to Info.plist
// <key>FirebaseAnalyticsDebugEnabled</key>
// <true/>Wait a few minutes and check that your events appear in the Firebase Console.
Important considerations:
1. Parameter value limits: In addition to the 25-parameter limit, Firebase Analytics also has limits on parameter values:
- Parameter names: 40 characters max
- Parameter values: 100 characters max (for text values)
- Parameter values that exceed limits are truncated
2. Event name limits: Event names are limited to 40 characters
3. Global limits: Remember these other Firebase Analytics limits:
- 500 distinct event types
- 50 text parameters per project (across all events)
- 50 numeric parameters per project (across all events)
4. Best practices for high-volume apps:
- Use BigQuery export for complex analytics needs
- Consider using User Properties for user-level attributes instead of event parameters
- Implement client-side sampling for very high-volume events
- Use parameter hashing for sensitive data (be mindful of GDPR/CCPA)
5. Migration strategy: If you're refactoring an existing app with many events exceeding the limit:
- Phase 1: Implement validation to prevent new violations
- Phase 2: Create a migration plan for existing events
- Phase 3: Update event logging incrementally, monitoring analytics continuity
Note on "Code 5": The specific error code "5" may vary between Firebase SDK versions and platforms (Android, iOS, Web). Always refer to the latest Firebase documentation for your specific platform.
messaging/UNSPECIFIED_ERROR: No additional information available
How to fix "messaging/UNSPECIFIED_ERROR: No additional information available" in Firebase Cloud Messaging
App Check: reCAPTCHA Score Too Low
App Check reCAPTCHA Score Too Low
storage/invalid-url: Invalid URL format for Cloud Storage reference
How to fix invalid URL format in Firebase Cloud Storage
auth/missing-uid: User ID identifier required
How to fix "auth/missing-uid: User ID identifier required" in Firebase
auth/invalid-argument: Invalid parameter passed to method
How to fix "auth/invalid-argument: Invalid parameter passed to method" in Firebase