Analytics & Digital Marketing Tips

Mobile App Analytics Tracking Using Firebase and GTM: Track Engagement and eCommerce

Mobile App Analytics Tracking Using Firebase and GTM: Track Engagement and eCommerce

September 11, 2018           Analytics

Mobile app analytics has quickly become just as important as web analytics. But you’re seeing all of your mobile app reporting data and making the best decisions, right? Maybe not. App analytics is still evolving and can vary wildly between mobile app development platforms, as well as the different interfaces.

So, why does this matter to you?

App store downloads are currently reaching over 100 billion, and by 2020 app stores and in-app advertising revenues are forecasted to reach nearly 189 billion dollars. If you’re not paying close attention to what your customers are doing in your app, and optimizing their experiences, your organization could be missing out on millions in revenue. Even more important, you may miss the opportunity to increase brand affinity, which will protect and help sustain your recurring revenue stream.  

Analytics data within your mobile app goes way beyond just downloads and views, and can provide you with important insights such as:

  • What features in your app are being used?
  • What are the search terms used?
  • How does the conversion funnel look?

By measuring your app engagement and gathering conversion funnel data, you can continuously work towards a better user experience and increased conversion rates.

Mobile App Tracking + Tag Management Systems

Using a Tag Management System, instead of implementing analytics code directly inside the app, means you won’t have to re-build and distribute your app when you have a change in analytics parameters, event structure, or naming conventions. Using a Tag Management System eliminates the dependency that forces your customers to update the app before the data begins collecting harmoniously. Just like how you use a Tag Management System on your website, you would use it on the app, sending data to your analytics platform.

Keep in mind that using a Tag Management System on mobile apps is not as powerful as on a website. You are constrained in terms of available functions and tags to those that the Tag Management System directly supports. For example, not all marketing vendor tags natively integrate with Google Tag Manager’s mobile app containers, but the list is growing and catching up with those available on web containers.  

App Analytics Tracking Success Begins With A Solid Strategy

Your app analytics strategy must start with your business objectives and KPIs. For example, if you have an eCommerce app, make sure the KPIs have eCommerce metrics that reflect your overall business strategy. When you draft your mobile app analytics KPIs, make sure to also align them with those of your website (if you have one).

Your app analytics strategy must start with your business objectives and KPIs.

Integrating data together from web and mobile is a must in order to look at your business and customer data holistically. Multiple platforms doesn’t mean you that you should look at your data and customer behavior in silos, you gain much more by combining the data and seeing how your marketing efforts work together on different platforms. At Blast, we have architected rollups for website and mobile app analytics in Google Analytics and Adobe Analytics. For example, if your website measures pageviews and your app measures screenviews, we can break those out by platform, or roll them up into one view. 

Using a standardized event structure, and similar naming of pages and screens are a few of the many ways to enable cross-device rollups to understand the customer journey across platforms.

An effective analytics strategy will outline your app tagging plan to go inline with your web tagging and will define how you measure the two platforms. A beautiful thing happens when results are married together: they live happily ever after.  

Google Tag Manager + Firebase = Mobile App Analytics for the Win

Whether you have an iOS or Android app, you can use Firebase with Google Tag Manager (GTM) to track engagement and eCommerce activities on your mobile app. 

In case you’re not familiar with Firebase, it is Google’s mobile platform that helps you quickly develop high-quality apps, and provides support for messaging, crash-reporting (i.e. Crashlytics), analytics, performance monitoring, and more.

It is simple to get started. Once you import the necessary Firebase libraries into your app, you can start sending data into Google Analytics through Firebase events that Google Tag Manager will process and send over to Google Analytics (or other supported tags). Below is a high level summary of the steps needed to implement mobile app analytics using Firebase and Google Tag Manager, followed by a tutorial.

Steps to Implement Mobile App Analytics

Tip: I highly recommend doing a “dry run” before you code your entire app and build all tags; Coding a single interaction to make sure it works first helps cut down your troubleshooting time and gets you started on the right track.

Step 1: Get Ready

  1. Create a new project on the Firebase Console, and add your app details (you will need the iOS bundle ID or Android package name)
  2. Create a new GTM Container based on your app’s operating system, choosing Firebase as the SDK version.

Step 2: Get Set

  1. Publish and Export the GTM container (it can be empty without tags)

Tip: Make sure you publish the GTM container initially, or Firebase will throw the error “Can not retrieve container from network.”

  1. Add Firebase and Google Tag Manager to your app. Follow the instructions in the developer docs for iOS, Android on what you should add to your app project and how.
    *Note: that if you’re running campaigns, it’s recommended that you also enable the AdSupport Framework.

Tip: For mobile Google Tag Manager containers, the initial container import is used to set initial tag configurations. Once the app has connected to the internet and downloaded a container, it will never use the default container again. Applications typically check for container updates every 12 hours. So when you make changes in your GTM container, don’t expect to see the impact on your app right away.

Step 3: GO

  1. In GTM, create your tracking tags, using the Firebase parameters (or built-in variables) as the data in your tags, and the events you log as the tag triggers.
  2. On the app, start sending data by logging events in your app through Firebase “Log Event” calls. Or utilize the built-in Firebase events that are also available in GTM as triggers.  

GTM + Firebase Tutorial: Mobile Analytics Tracking Fundamentals

This tutorial demonstrates the tracking code using iOS Swift; refer to Firebase reference for code syntax for both Swift or Objective-C on iOS as well as Android syntax.

Real World Use Case

You have a travel guide app and you want to track when the user clicks on the bucket icon to add a destination or activity to his/her app “bucket list” with full interaction details as an event in UA. BUT, you also want to track his membership level and device language.

image representing the travel guide scenario and google analytics

The Google Analytics hit details above is what should be highlighted in your analytics strategy, with details of data types and variable names on all platforms. Following is a walkthrough of the Google Tag Manager and Firebase setup to track this engagement interaction.

  • Membership Type: User Property Variable

User properties in Firebase are attributes you define that you can use to describe segments of your user base. In this example, you need to set the membership level user property when the member logs in by using the setUserProperty function and it becomes readable by GTM at anytime after it has been set.    

image representing user property in gtm and firebase

  • Language: Built-in Variable

The parameter value for ‘device language’ can be detected automatically in Google Tag Manager, no coding is needed in the app. In GTM, Configure the Built-in Variables and enable ‘Language.’ This will automatically create a variable named ‘Language’ that you can use in tags.

image representing device language in gtm and firebase

  • Add to the bucket list: Custom Event & Event Variables

For all the other parameters which are known at the time of the interaction event, you must create event variables in Google Tag Manager, similar to how you create dataLayer variables in web GTM containers. The screenshot from GTM below shows the setup for list_item parameter, the same should be done for list_type and section event parameters. The Firebase code logs the custom event “add_to_bucket” along with its parameters. Note that although we will be tracking the membership type and Device Language with this event, they’re not part of the logEvent code as they’re already setup as a user property and a built-in parameter that are automatically detected in GTM.

image representing gtm event parameter and firebase code

  • Track the Interaction as Google Analytics event

Create a tag in Google Tag Manager to configure the event tracking and map the the variables to the Google Analytics dimensions for the event hit.

image representing how to configure event tracking in gtm

As for the trigger, you would base it on the custom event name that will be used in the code

image representing google tag manager custom event name that will be used in the code

Voilà! Now publish the Google Tag Manager container to start tracking your mobile app analytics!

Use Case Summary

This quick tutorial demonstrated how to use custom events to track your app interactions; you can do the same customizations for screenviews or any type of user engagement that you wish to track. However, always try to optimize your events and Google Tag Manager container by looking at your analytics tracking strategy, and see what interactions could use the same tags or events, and how using parameters can help you reuse tags and triggers.

Always try to optimize your events and GTM container by looking at your analytics tracking strategy, and see what interactions could use the same tags or events…

In our example, we could have the “Add to Bucket List” interaction somewhere else in the app, such as the Home screen, where you suggest destinations to your app users based on their history. You can trigger the same GTM and Firebase code, just changing the parameter value for “section” to be “Suggested Destinations.” This is the fruit of using a Firebase tagging plan that is based on the analytics strategy; making that code reusable in your app as a function and also resulting in a lighter Google Tag Manager container.

And remember, if you have the same interaction of “Add to Bucket List” in your website, you can use the same event parameter structure along with custom dimensions, so when you roll up your app and web data, you have consolidated data on the engagement without the need to do any data manipulation or calculations.

Don’t Forget: Always Test!

You can test your code and debug by using the Firebase Debug view in the Firebase console. Stay tuned for the next post on more details for testing and troubleshooting Firebase + Google Tag Manager implementations with our Decoder tool.

Bonus! GTM + Firebase Tips

  • If you have user profile data that’s used in more than an event, set them as a user properties so they’re accessible through GTM datalayer at anytime; thus minimizing your app rebuilds and updates.
  • Build a generic “Google Analytics Event” in Firebase and GTM to be used for all interactions that are tracked as events in Google Analytics.image representing mobile app analytics
  • Use built-in GTM variables when you can, especially if you’re tracking in-app marketing campaign data or in-app purchases. See the list of built-in variables for iOS and Android.
  • Set a default value to your variables, Firebase generates warnings for null values that could interfere with your analytics tracking.
  • Make use of the events that are automatically triggered by Firebase; when creating GTM tag triggers, select them from “Firebase Automatic Events”. This also won’t require you to do any app rebuilds. See the list of the automatically collected events.

How’s that for Crash a Course?

Our quick tutorial of using Firebase Analytics with Google Tag Manager is complete! Give it a try on your app and ask us questions or tell us how it went in the comments! Stay tuned for another blog post on troubleshooting app analytics with Firebase, where we’ll share our proprietary tool that helps you review your tracking tags, and validate your mobile app analytics implementation in real-time.

 

  • Great post!! Analytics data within your mobile app can provide you important data regarding what features in your app are being used, search terms that are used the most and about conversion data.

  • Mai Alowaish

    Thank you for your feedback! App analytics data can provide all of that and more when integrated with your web analytics data to look at your customer behavior holistically.

  • andiansyah

    Hi mai,
    Thank you for the post,
    We’ve already use GA , Now we’d like to implement Firebase and GTM to our app. Could you please help me to understand two things:

    1.Should Tag be implemented to GTM or they need to be implemented in app’s code?

    2.Should we remove all implemented code before from the app and use only GTM tags?

    Thank you

  • Mai Alowaish

    You’re welcome! Answers to your questions.
    1. Tags must be implemented in GTM . All tracking and marketing tags go in your tag manager.
    2. If the implemented code is the legacy GA SDK , then yes you should removed it. You do not need any GA calls from your app code. All you need to use is Firebase events (logEvent) calls to send events and variables to GTM for processing.

  • andiansyah

    Hi mai,
    One more thing,
    Do you have reccomendations to doing ‘Dry Run’? do we have Coding a single interaction and then publish the apps? or Coding a single interaction, testing and then we code entire apps and publish?

  • Pam

    Hi Mai,

    Very good and useful post!

    Just wondering, since you’re using Firebase, why are you logging the Universal Analytics tags rather than Firebase ones? Would you recommend still using GA rather than the Firebase reports?

    Thanks
    Pam

  • Mai Alowaish

    For the dry run, it can be any of the two ways you mentioned.

    From my experience, if you already have a lot of traffic on the app, I would do the single interaction and then publish the app; to uncover any issues or bugs that you may have as they will be useful to know while you’re implementing the other interactions and will save you a lot of time in redoing the code. Even if you do your testing, heavy traffic can uncover a lot of data handing errors (so make sure you log errors as GA events in this period to collect data).

    If your app is new , then coding the single interaction and just confirming that data is getting through to GA through local testing should be sufficient to start coding the entire app and then publish.

  • Mai Alowaish

    Hi Pam,

    Thank you for your feedback!

    Using Google Analytics (for Firebase) or Google Analytics (Universal Analytics) is really a choice that depends on different factors on how you will use the data and whether the app is a standalone app or there is also a website or other platforms that serve the same function in your business model.

    In my example, I used Universal Analytics assuming that the app analytics data will be merged with the website analytics data together in a Rollup account in GA to look at customers’ interaction holistically and be able to to study user’s behavior across devices easily in one GA property (the roll up property).

    You can use GTM to track your app traffic in both Google Analytics for Firebase or Universal Analytics; both are supported as tags in GTM for Firebase containers.

    So if your business already has websites collecting data and you see value of merging that with your app analytics data, then my recommendation is to use GTM to track your data into Universal Analytics.

    However, if you only want to analyze your app data and you have limited interactions, then using Google Analytics for Firebase may be a better option since it automatically tracks a lot of the events and user properties, and then you can use GTM as well if you needed to add custom events or track other supported marketing tags through GTM (Floodlight counters, GoogleAds conversions, Kochava..etc).

  • Pam

    thank you for coming back to me! I understand now 🙂
    Yes, I am looking to track the usage of our iPad app – it’s replacing a paper-based solution so understanding how users use the app and where they struggle will be crucial 🙂
    I am not sure if Firebase Analytics will be the best way to go. I’m thinking of maybe using Heap Analytics as it tracks every interaction on the app out of the box, whereas with Firebase Analytics, I’d need to log a lot of the events manually.

  • Mai Alowaish

    Hi again,
    I understand more about your requirements now.
    If you use Firebase Analytics , then you will not need to log events manually. see the link below for the full list of automatically tracked events in Firebase Analytics (aka Google Analytics for Firebase). As long as you use the Firebase SDK, you don’t need to write any additional code to collect these events. It covers most of the engagement in apps:
    https://support.google.com/firebase/answer/6317485?hl=en

    Note that these events are tracked in Firebase analytics, not universal analyltics. so most of the app interactions (screenviews, notifications, session starts, app updates or in-app purchases) are already tracked without having to do any custom work.

    The examples we had in this blogpost are for tracking into Universal analytics , this is why events were logged manually in the example code.

 

Connect with Blast Analytics & Marketing



Connect with us on LinkedIn