Skip to main content
skill CX Codex

firebase-analytics · evanca — Claude Code skill: setup and install

firebase-analytics is a Claude Code skill for configuring Firebase Analytics in Flutter apps. It activates for event logging, user properties, funnels, and screen-view tracking.

MIT ★ 674 updated 2026-10-29

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add evanca/flutter-ai-rules
/plugin install flutter-ai-skills@flutter-ai-rules
Open on GitHub

What firebase-analytics does

The skill guides Firebase Analytics setup in a Flutter project, including package configuration, predefined and custom events, user properties, and default event parameters. For screen tracking, it covers Navigator observers and logging route changes with GoRouter.

Call Firebase.initializeApp() before accessing FirebaseAnalytics.instance. Events can be checked in Firebase DebugView; event names are case-sensitive and limited to 40 characters. For iOS apps that do not use IDFA, the instructions describe an Analytics dependency that omits the advertising identifier.

What it helps with

  • add Firebase Analytics to a Flutter project
  • log predefined or custom analytics events
  • set user properties and default event parameters
  • track screen views and route changes
  • verify incoming events in Firebase DebugView

Example prompts for the agent

  • Set up Firebase Analytics in my Flutter app.
  • Add an add_to_cart event with product and price parameters.
  • Track screen views when routes change in GoRouter.

How to install firebase-analytics

1Plugin marketplace

/plugin marketplace add evanca/flutter-ai-rules
/plugin install flutter-ai-skills@flutter-ai-rules

This installs the whole flutter-ai-skills plugin with all its skills

2Skills CLI (Vercel)

npx skills add evanca/flutter-ai-rules --skill firebase-analytics -a claude-code

3Manually: put the files in place

~/.claude/skills/firebase-analytics/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/firebase-analytics/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about firebase-analytics

How do I install firebase-analytics in Claude Code?

Add the marketplace with /plugin marketplace add evanca/flutter-ai-rules, then install the skill with /plugin install flutter-ai-skills@flutter-ai-rules.

What does firebase-analytics do?

It guides Firebase Analytics implementation in Flutter apps, covering event logging, user properties, default parameters, screen tracking, and event checks.

What does firebase-analytics need to work?

The Flutter project needs the firebase_analytics package. Call Firebase.initializeApp() before accessing the analytics instance.

Source text

SKILL.md · MIT
---
name: firebase-analytics
description: "Use when logging analytics events, setting user properties, configuring default event parameters, building funnels, or adding screen-view tracking."
license: MIT
---

# Firebase Analytics Skill

This skill defines how to correctly implement Firebase Analytics in Flutter applications, covering setup, event logging, user properties, and data collection best practices.

## When to Use

Use this skill when:

* Setting up and configuring Firebase Analytics in a Flutter project.
* Logging predefined or custom analytics events.
* Setting user properties or default event parameters.
* Implementing screen view tracking with GoRouter or Navigator observers.
* Building conversion funnels or tracking user flows.

---

## 1. Setup and Configuration

```
flutter pub add firebase_analytics
flutter run
```

```dart
import 'package:firebase_analytics/firebase_analytics.dart';

// After Firebase.initializeApp():
FirebaseAnalytics analytics = FirebaseAnalytics.instance;
```

- Initialize Firebase before using any Firebase Analytics features.
- Analytics **automatically logs** some events and user properties — no additional code needed for those.
- On iOS, if your app does not use the IDFA (Advertising Identifier), use the IDFA-free Analytics dependency (`FirebaseAnalyticsCore` under Swift Package Manager, or `FirebaseAnalytics/Core` under CocoaPods) instead of the default `FirebaseAnalytics` dependency to avoid App Store review questions about advertising identifiers:
  - **Swift Package Manager:** set `FIREBASE_ANALYTICS_WITHOUT_ADID=true` when building (`FIREBASE_ANALYTICS_WITHOUT_ADID=true flutter build ios`).

### Add Navigator Observer for Automatic Screen Tracking

```dart
MaterialApp(
  navigatorObservers: [
    FirebaseAnalyticsObserver(analytics: FirebaseAnalytics.instance),
  ],
);
```

For GoRouter, log screen views manually on route changes:

```dart
GoRouter(
  observers: [FirebaseAnalyticsObserver(analytics: FirebaseAnalytics.instance)],
);
```

### Verification Checklist

1. Confirm `Firebase.initializeApp()` completes before accessing `FirebaseAnalytics.instance`.
2. Run the app and check the Firebase DebugView console for incoming events.
3. Confirm automatic events (`first_open`, `session_start`) appear without extra code.

---

## 2. Event Logging

Use **predefined event methods** when possible for maximum detail in reports and access to future Google Analytics features:

```dart
await FirebaseAnalytics.instance.logSelectContent(
  contentType: "image",
  itemId: itemId,
);
```

Use the general `logEvent()` method for both predefined and custom events:

```dart
await FirebaseAnalytics.instance.logEvent(
  name: "select_content",
  parameters: {
    "content_type": "image",
    "item_id": itemId,
  },
);
```

### Custom Event Example — E-commerce Add-to-Cart

```dart
Future<void> logAddToCart(String productId, String productName, double price) async {
  await FirebaseAnalytics.instance.logEvent(
    name: 'add_to_cart',
    parameters: {
      'product_id': productId,
      'product_name': productName,
      'price': price,
      'currency': 'USD',
    },
  );
}
```

- Event names are **case-sensitive** — names differing only in case create two distinct events.
- Up to **500 different event types** with no limit on total event volume.
- Event names must start with an alphabetic character, contain only alphanumeric characters and underscores, and be no longer than **40 characters**.

---

## 3. Parameters and Properties

- Parameter names: up to **40 characters**, must start with an alphabetic character, contain only alphanumeric characters and underscores.
- String parameter values: up to **100 characters**.
- The prefixes `firebase_`, `google_`, and `ga_` are **reserved** — do not use them for parameter names.
- Up to **25 custom parameters** per event.
- Register custom parameters in the Analytics console to use them as dimensions or metrics in reports.

Set default parameters for all future events (not supported on web):

```dart
await FirebaseAnalytics.instance.setDefaultEventParameters({
  'app_version': '1.2.3',
  'environment': 'production',
});
```

Clear a default parameter by setting it to `null`.

---

## 4. User Properties

```dart
await FirebaseAnalytics.instance.setUserProperty(
  name: 'favorite_food',
  value: favoriteFood,
);
```

Set the user ID to correlate events across devices:

```dart
await FirebaseAnalytics.instance.setUserId(id: 'user_12345');
```

- Create custom definitions for user properties in the Analytics console before using them.
- Up to **25 custom user properties** per project.
- Use user properties for audience segmentation, report filtering, or A/B test targeting.

---

## 5. Best Practices

- **Request necessary permissions** before collecting user data, especially on platforms with strict privacy controls.
- **Never log** sensitive or personally identifiable information in events or user properties.
- Use **consistent naming conventions** (snake_case) for custom events and parameters.
- Group related events to track user flows and conversion funnels.
- Use **DebugView** in the Firebase console during development — enable it on a physical device with:
  - **Android:** `adb shell setprop debug.firebase.analytics.app <package_name>`
  - **iOS:** Add `-FIRDebugEnabled` to scheme arguments in Xcode.
- **Test** analytics implementation before deploying to production by confirming events appear in DebugView.

---

## References

- [FlutterFire GitHub Repository](https://github.com/firebase/flutterfire)

© Ivanna Kaceviča · MIT · evanca/flutter-ai-rules

Similar skills

All skills for Mobile →

firebase-analytics by other authors comes first.

From the same set39

The whole set →
flutterfire-configure Guides Firebase integration in Flutter apps, runs flutterfire configure, and structures multi-flavor project environments. CX Codex +1 ★ 674repo stars flutter-use-column-row-first The flutter-use-column-row-first skill guides Flutter screen layouts with Row, Column, and flexible space. Use it when building a screen that must adapt to different constraints. CX Codex +1 ★ 674repo stars firebase-crashlytics Skill teaches the agent to set up Firebase Crashlytics in Flutter projects: catch fatal and non-fatal errors, log async exceptions, add custom keys, and upload obfuscated build symbols. CX Codex +1 ★ 674repo stars firebase-in-app-messaging Guides Firebase In-App Messaging setup in Flutter: trigger and suppress popups during sensitive flows, configure GDPR opt-in collection, and run tests via test device IDs. CX Codex +1 ★ 674repo stars patrol-e2e-testing patrol-e2e-testing is a skill for building and running Patrol 4.x end-to-end tests for Flutter apps, covering user flows, OS permission dialogs and cross-platform checks. CX Codex +1 ★ 674repo stars revenuecat-testing revenuecat-testing builds a structured QA plan for RevenueCat in-app subscriptions, verifies sandbox events, and debugs purchase restore flows. CX Codex +1 ★ 674repo stars firebase-app-check This skill guides Firebase App Check setup in Flutter, including provider choice, debug tokens, token refresh, and enforcement rollout. CX Codex +1 ★ 674repo stars flutter-best-practices flutter-best-practices is a Claude Code skill with rules for Flutter and Dart: layers, feature folders, widget choices, and tests. The agent reads the reference file matching the task. CX Codex +1 ★ 674repo stars

Project sponsors

Companies that keep this analytics open