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.

  • Beautiful Owl

    Hello Mai, really great post. Thank you !
    We`re try to implement firebase and gtm to our app and send events to our ga account and everything works fine except one thing – custom dimensions. I cant understand how to set up custom dimensions (as you I put custom dimension “Language” in the tag and nothing). Should I use Data Layer ? as I read Firebase is our data layer and we dont need to write it in our app`s code, is it true ?

  • Mai Alowaish

    Thank you for your feedback!
    To add a custom dimension, it needs to be added in the tag, which you already did, and the second part is to make that value available.
    If you want to track the device language just like in the example provided in the post here, then you need to go into GTM, and go to the Variables tab, and under the “Built in Variables” , click on the configure button to enable the “Language” variable and then just use that in the tag (screenshot of the variable is above in the blogpost) , variable name will be {{Language}}. no data layer or extra coding needed
    see full list of built in variables for GTM and Firebase here https://support.google.com/tagmanager/answer/7182836?hl=en

    Make sure the custom dimension is already setup in your Google Analytics with the appropriate scope and that you’re using the correct index.
    see steps here: https://support.google.com/analytics/answer/2709829?hl=en

    A good way to troubleshoot if there’s an issue with the Language parameter specifically, is to pass a hardcoded value in your GTM tag for a custom dimension and see if that gets thru to GA?

    let me know if you have further questions!

  • disqus_OHHGntxVmN

    Hi Mai, Great article, but I’m still confused and feel like I’m missing the point of using GTM at all on an app.

    If GTM needs Firebase to effectively be its datalayer, if there is no need for any third party tools to use that data, is there any point?

    If I can send an event to Firebase using either the Firebase SDK or GTM SDK, why bother with GTM? It feels like an extra step with no point. As an aside, if you use GTM to send events, how do you prevent Firebase from also sending the event.

    My understanding is that this is only of value if you send data to Google Analytics AND Firebase – but if you’re only using Firebase then is it needed?

    Thanks – keen to hear where I’ve gone wrong.

    J

  • Mai Alowaish

    Thank you for your feedback and question!
    You are correct in that GTM may not add much value if you’re using “Google Analytics for Firebase” for your app analytics , and your goal is just analytics tracking, because everything is automatically tracked into “Google Analytics for Firebase” through the Firebase SDK, and all GTM can add to that is to modify or block these automated events.
    However, if your tracking goals include marketing tags ( such as Floodlight counters and sales pixels, GoogleAds conversion tracking, Kochava..etc), then using GTM will add value since you will not have to implement these on your app (GTM has built-in tags for them) and you will share the same datalayer for all these pixels resulting in better performance and management of your tracking pixels, all through GTM.

    If you are tracking your analytics data in Universal analytics, then it would be recommended to use GTM since the GA SDKs for iOS and Android are now legacy, and Google recommended upgrading to use Firebase.

  • disqus_OHHGntxVmN

    Thanks Mai,

    So once the iOS and GA SDKs are legacy, you can still leverage GTM to send data to GA? Will that be a standard GA account or with there still be an option to have a ‘app’ version of a Google Analytics account.

    So, if we only ever intend to run analytics, Firebase is enough. However, if we plan to use other third party tags, then GTM is a must.

    Out of interest, speaking or marketing tags, how would you track Facebook ads in Firebase?

    Also, if you used dynamic links on your desktop website to send a link to your mobile device to prompt use or download of the app – is there anyway to maintain Ad attribution for ad clicks that drove users to the original interaction on desktop? I.e. user clicks ad > user lands on website > user clicks dynamic link > user opens link on mobile > user does stuff on app. Can that ‘stuff’ be attributed back to the original ad?

    Sorry waaaay off-topic there but I started reading up on some of the points made in your previous reply and I went down a bit of a rabbit hole…keen to hear your thoughts.

    Thanks J

  • Mai Alowaish

    You’re welcome.

    Currently GTM supports both Universal Analytics and “Google analytics for Firebase” tags; so Firebase+GTM would replace the legacy GA SDK if you plan to send traffic to a standard GA account. Things change every day and recently there was a change that if you want to create an app property (not view), Google Analytics is requiring you to use Firebase.

    Facebook is not on the GTM built-in tags list, and GTM for Firebase doesn’t support custom code. so you may use the AppEvents of Facebook (through Facebook SDK) directly on your app; one way to utilize GTM in this case is to use GTM to trigger certain classes in your app (for example a class to trigger the Facebook AppEvent).
    see full list of supported tags in GTM Firebase containers: https://support.google.com/tagmanager/answer/6106924?hl=en

    Interesting attribution question! this can be done in different ways depending on how you run your website, and the amount of ads and dynamic links you have. one way is to add some logic in your website to use certain links based on the ad that they arrived through (probably parsing certain parameters and sessioning them); at the same time, having your dynamic links have campaign parameters specified that relates them back to the ad, find more details here about campaign parameters on dynamic links: https://firebase.google.com/docs/dynamic-links/analytics#google-analytics-for-firebase (Scroll down to the “Google Analytics and Apple App Analytics campaign parameters” section) . and see the example code here adding campaign details in “Dynamic Link parameters”
    https://firebase.google.com/docs/dynamic-links/ios/create
    let me know if that answers your question?
    It’s worth mentioning that in a recent custom implementation that I’ve done, we have passed custom firebase UTM parameters through GTM for a similar problem, to attribute traffic on where they started. so it can be done with or without GTM depending on the scenario you have.

    let me know if you have other questions!

  • disqus_OHHGntxVmN

    Great, thanks Mai.

    I didn’t know about the AppEvent for Facebook, that’s great thanks. What about other ads, such as Instagram etc. How do you implement platforms with no custom or native tags.

    Interesting attribution solution – so we test for the ad the user clicks, extract relevant parameters and then build a dynamic link on the fly. I assume these parameters survive app installs too. One quick question – one a user lands via these custom dynamic links, how are these extracted and reported within Firebase.

    My very last question (I promise) extracting Firebase data to Google Data Studio via BigQuery – my understanding is that you effectively export all Firebase data to BigQuery, GDS then reads from BigQuery so if you change dates etc. in GDS the data pulled from BQ is updated. Do you know of any good resources for this?

    Thanks once again.

  • Mai Alowaish

    Glad that helped!

    For the dynamic links, make sure you have utm parameters as part of the link in order for the data to be available in firebase and GA . If you’re in the firebase console, you can see the source, medium and campaign when you click on the Conversion from the conversions tab.

    as for using GDS and BigQuery , checkout these resources that are helpful to do this. It is a bit more complicated working with BQ as a data source as opposed to GA, let us know if you have further questions!
    https://cloud.google.com/bigquery/docs/visualize-data-studio
    and this use case: https://cloud.google.com/blog/products/gcp/how-to-build-a-bi-dashboard-using-google-data-studio-and-bigquery

  • MI FourTwoOne

    Hello,
    Is it possible to track url click links, banner clicks, slider clicks , button clicks in My Android App and analytics for all.

    Which one is helpful Google tag Manager, Events, Firebase, Dynamic Links…e.tc

  • Mai Alowaish

    To track clicks on any elements in your app, you can use the logEvent method to track the clicks. See here for the Android reference for the logEvent method, including example code for a custom event named “share_image” in Google’s documentation
    https://firebase.google.com/docs/analytics/android/events

    The processing of the logEvent depends on where you want to track the click data: Google Analytics for Firebase, or Universal analytics (thru GTM) , or both, depending on your requirements.

    If you’re using Google Analytics for Firebase , the logEvent click will add the event name you pass to the event log, then you can use custom parameters to track extra details about the link.

    If you’re using Universal Analytics, make sure you have the click details passed as parameters with the logEvent and that you have the same parameters defined in GTM in order to pass the data using the analytics tag as event category, action or label. See above example in the blogpost on how we did the “Add to List” event.

    Keep in mind if you’re using Google Analytics for Firebase, clicks on ads and some other interactions are automatically tracked without any extra code or implementation needed; see this link for automatically collected events
    https://support.google.com/firebase/answer/6317485?hl=en

    you mentioned Dynamic links and these are actually used to track incoming traffic to your app, not clicks in your app; any app opens through Dynamic links are automatically collected events.
    more details here : https://firebase.google.com/docs/dynamic-links/

 

Connect with Blast Analytics & Marketing



Connect with us on LinkedIn