Mobile App Analytics Tracking Using Firebase and GTM: Track Engagement and eCommerce
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).
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
- Create a new project on the Firebase Console, and add your app details (you will need the iOS bundle ID or Android package name)
- Create a new GTM Container based on your app’s operating system, choosing Firebase as the SDK version.
Step 2: Get Set
- 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.”
- 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
- 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.
- 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
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.
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.
- 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.
- 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.
- 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.
As for the trigger, you would base it on the 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… Click & Tweet!
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.
- 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.