Google Analytics

Cloud Functions and Google Analytics for Firebase

At the core of the Firebase mobile platform, Google Analytics for Firebase provides a range of insights into mobile app lifecycle events, as well as a wide variety of out-of-the-box and customizable events and user properties that can support additional analysis.

What if we could extend the functionality of Firebase even further? Because Firebase is built on Google Cloud Platform, we can trigger Google Cloud Functions using Google Analytics for Firebase, thereby taking further back-end actions based on user interactions with our mobile apps.

What Are Cloud Functions?

Cloud Functions are part of the Google Cloud Platform (GCP). Cloud Functions let you write and deploy code that responds to events from Google Cloud Services, including Firebase products like Google Analytics for Firebase. (As another use case for Cloud Functions, check out Taha’s post about the integration of Cloud Functions and BigQuery).

When you create a Firebase project, you’re creating a Google Cloud project behind the scenes.
Source: Firebase YouTube Channel
Firebase project as displayed in the Firebase console
When you create a Firebase project, you are actually creating a Google Cloud project behind the scenes. You can edit your Cloud functions from either the Firebase or Google Cloud console.

What can you do with Cloud Functions?

Cloud Functions allow you follow up on user actions in a variety of ways. Using Firebase conversion event triggers (outlined below), you can use Cloud Functions to:

  • send a welcome email when a user completes signup
  • send a coupon when a user completes a purchase
  • send an SMS confirmation when a user creates a new account

Using Real-time Database Triggers, you could:

  • notify users when something interesting happens within the app

From an architecture perspective, you could use Cloud Storage triggers to:

  • execute intensive tasks (heavy CPU or networking) in the cloud instead of in the app
Several of the triggers that you can configure for a Cloud Function relate to Firebase activity.
You can use Cloud Functions to send an email when a user completes a signup process.
Source: Firebase YouTube Channel
You could configure a Google Cloud Function that is triggered when a new record (for a follower in a mobile app, as an example) is created in the Firebase Realtime Database. You could write the function to send a Firebase Cloud Messaging notification to the user who was followed.
For instance, you could write a function to listen for image uploads to Storage, download and modify the image to the instance running the function, modify it, and upload it back to Storage.
Source: Firebase Docs

Creating Cloud Functions

To create cloud functions, there are two methods:

  1. Using the Command-Line Tool:
    In this method, you will use The Firebase CLI (Command Line Interface), Node.js, and npm (the Node Package Manager) to create a cloud function. Get started here.
    Using the Firebase CLI to Create Cloud Functions
  2. Using the GCP Console:
    In this method, you create and deploy the cloud function on the Google Cloud Platform after linking your Firebase Project to it.
    Using the GCP Console to Create Cloud Functions

What are Analytics Conversion Events?

Conversions are your most important events. You can designate up to 15 events per Firebase project as conversions, in addition to the three default conversions (first_open, in_app_purcase, and ecommerce_purchase). Only events marked as conversion events are currently supported by Cloud Functions. We can specify which events are conversion events in the Events tab of the Firebase console Analytics pane.

Analytics Events Panel in Firebase; you can choose to mark an event as a conversion
Once you have designed a Firebase event as a conversion, it appears in the Conversion Panel.
Specify the name of the conversion event that will trigger your cloud function.

A Note on Sunsetting the Google Analytics Services SDKs

Last year, the Google Analytics team started to send some of you a note to let you know that in October 2019 they will begin to sunset the Google Analytics for mobile apps reporting and the Google Analytics Services SDK. Here are the main points you should remember:

  1. Data collection and processing for such properties will stop on October 31, 2019.
  2. Reporting access through The Google Analytics UI and API access will remain available for these properties’ historical data until January 31, 2020.
  3. After the service is fully turned down, these properties will no longer be accessible via the Google Analytics UI or API, and their data will be removed from Google Analytics servers.

My friend Tara Kincade wrote a comprehensive post about this topic, but the main point here, if you are not a Firebase – Google’s integrated app developer platform – user yet, you have to consider the transition to be able to benefit from its solutions best-in-class with new features and capabilities rolling-out continually like Analytics and Cloud Functions that we explored above.

Contact us today to learn more about how we can help you get the most benefit from Google Analytics for Firebase and Google Cloud Platform.
CP Marketing

Share
Published by
CP Marketing

Recent Posts

Optimizing user experiences with Digital Experience Analytics (DXA) platforms

As consumers become increasingly digitally savvy, and more and more brand touchpoints take place online,…

1 month ago

Enabling Value-Based Bidding with Google Tightlock

Marketers are on a constant journey to optimize the efficiency of paid search advertising. In…

1 month ago

Resolving “Unassigned” Traffic in GA4

Unassigned traffic in Google Analytics 4 (GA4) can be frustrating for data analysts to deal…

2 months ago

This website uses cookies.