> ## Documentation Index
> Fetch the complete documentation index at: https://documentation.onesignal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Analytics for Firebase

> OneSignal will automatically send notification events to your analytics dashboard if Google Analytics for Firebase is correctly implemented. Works with iOS and Android.

[Google Analytics for Firebase](https://firebase.google.com/products/analytics) is an event-tracking tool provided for free by Google Firebase. It allows you to easily track events within your app and analyze them later using various filters.

<Warning>
  This integration does not support UTM parameters to the launch URL.

  On Web, the GA code will capture the values based on URL in the browser.

  On Mobile, you will need to capture these values and pass to GA. Our Notification Opened Event Handler can be used to get the notification payload.
</Warning>

## Events

The OneSignal SDK tracks events that pertain to notification open & receive events. The following events are sent:

| Event Name                       | Details                                                                                                                                   |
| -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `os_notification_opened`         | A OneSignal notification was opened                                                                                                       |
| `os_notification_received`       | A OneSignal notification was received. (**Android Only**)                                                                                 |
| `os_notification_influence_open` | An application was opened within 2 minutes of a OneSignal notification being received. ([iOS requires additional setup](./ios-sdk-setup)) |

The OneSignal SDK also sends parameters which contain more info about the particular notification the event is attributed to:

| Parameter Name    | Parameter Value                                                                                                                                                    | Details                                                                                                              |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------- |
| `source`          | "OneSignal"                                                                                                                                                        | To attribute this event's source to the OneSignal SDK                                                                |
| `medium`          | "notification"                                                                                                                                                     | A formal indication that the medium for the event is a notification                                                  |
| `notification_id` | the `notification_id` from a particular OneSignal notification                                                                                                     | You can attribute a notification ID to a particular "sent" notification on the dashboard                             |
| `campaign`        | If using a template:`[template_name]-[template_id]` If not: First 10 letters of the `headings` [API property](/reference/push-notification) or notification Title. | Campaigns are a way to group notifications that are similar, such as notifications using the same template or title. |

***

## Setup OneSignal events integration with Google Analytics for Firebase

### Setup Firebase

Follow the [Firebase integration documentation](https://firebase.google.com/docs/android/setup) and verify that Firebase is correctly functioning inside your application.

### Enable Firebase in OneSignal

Navigate to **Data > Integrations** and enable **"Firebase"**.

This will begin sending event data to Firebase. If you wish to track influenced opens on iOS, you will need to perform some [additional setup](./ios-sdk-setup) due to limitations in Firebase.

<Frame caption="Firebase enabled in OneSignal">
  <img src="https://mintcdn.com/onesignal/yt4lRKoquAlWvRvF/images/integrations/Integrations.png?fit=max&auto=format&n=yt4lRKoquAlWvRvF&q=85&s=61a02b7a3829ff83ed2f1013c186b3e4" data-path="images/integrations/Integrations.png" />
</Frame>

### Verify OneSignal events

<Steps>
  <Step title="Check your app logs">
    Verify that Firebase is attempting to send events related to OneSignal notifications

    Check in your application's LogCat logs and look for Google Analytics for Firebase entries that indicate events corresponding to OneSignal are being sent. Look for `os_notification_opened`,`os_notification_received`, or `os_notification_influence_open`

    <Frame caption="Firebase events in LogCat">
      <img src="https://mintcdn.com/onesignal/6v_cVPknFpo5qSVB/images/docs/0dc5c63-firebase_analytics_3.png?fit=max&auto=format&n=6v_cVPknFpo5qSVB&q=85&s=0d20d440318aed8908313e89084d3bb9" width="1560" height="42" data-path="images/docs/0dc5c63-firebase_analytics_3.png" />
    </Frame>
  </Step>

  <Step title="Go to the Firebase console">
    Go to the [Firebase Console](https://console.firebase.google.com/) for your project

    <Frame caption="Firebase console">
      <img src="https://mintcdn.com/onesignal/MUgio66t0sYhGEvj/images/docs/646c537-firebase_analytics_1.png?fit=max&auto=format&n=MUgio66t0sYhGEvj&q=85&s=2637f7f9b40c23e5d69f0ab0510a127e" width="2878" height="1078" data-path="images/docs/646c537-firebase_analytics_1.png" />
    </Frame>
  </Step>

  <Step title="Follow the DebugView Setup Guide">
    Follow the [DebugView Setup Guide](https://firebase.google.com/docs/analytics/debugview)

    The DebugView allows ADB to send Firebase events to your project when it's in `debug` mode. Here is a great video on this for iOS: [https://youtu.be/kpkW78OSbiw?t=289](https://youtu.be/kpkW78OSbiw?t=289)

    Example Debug Logs

    ```text Xcode logs example theme={null}
      2021-09-22 14:58:20.731918-0700 OneSignalDemo[33301:1350721] 7.0.0 - [Firebase/Analytics][I-ACS023073] Debug mode is enabled. Marking event as debug and real-time. Event name, parameters: os_notification_opened, {
          campaign = Firebase t;
          ga_debug (_dbg) = 1;
          ga_event_origin (_o) = app;
          ga_realtime (_r) = 1;
          medium = notification;
          notification_id = 2ecdd9bf-b2c0-443e-b5b2-7983d453c746;
          source = OneSignal;
      }
      2021-09-22 14:58:20.749723-0700 OneSignalDemo[33301:1350721] 7.0.0 - [Firebase/Analytics][I-ACS023072] Event logged. Event name, event params: os_notification_opened, {
          campaign = Firebase t;
          ga_debug (_dbg) = 1;
          ga_event_origin (_o) = app;
          ga_realtime (_r) = 1;
          medium = notification;
          notification_id = 2ecdd9bf-b2c0-443e-b5b2-7983d453c746;
          source = OneSignal;
      }
    ```
  </Step>

  <Step title="Check the DebugView">
    As OneSignal events propagate, they will appear in real-time on the DebugView

    <Frame caption="DebugView">
      <img src="https://mintcdn.com/onesignal/_KaXe4GQkxsEfa17/images/docs/39a888e-Screen_Shot_2021-09-22_at_3.16.55_PM.png?fit=max&auto=format&n=_KaXe4GQkxsEfa17&q=85&s=3bebf24697b77a5cc2acb5b0a06aec87" width="3376" height="1756" data-path="images/docs/39a888e-Screen_Shot_2021-09-22_at_3.16.55_PM.png" />
    </Frame>
  </Step>
</Steps>

<Check>
  **Your application has been verified to track OneSignal notification events through Google Analytics for Firebase!**
</Check>

***

## FAQ

### Why are the clicked and opened events not showing in Firebase?

The Firebase click event `os_notification_opened` and received event `os_notification_received` may not work if the Firebase library has not initialized in time so the Firebase library drops the event. More details on [this github issue](https://github.com/OneSignal/OneSignal-Android-SDK/issues/949).

<Note>
  Link your Firebase Database and use Firebase Cloud Functions with OneSignal following our [Firebase Setup Tutorial](./google-analytics-for-firebase).
</Note>

***
