Reader small image

You're reading from  Firebase Cookbook

Product typeBook
Published inNov 2017
PublisherPackt
ISBN-139781788296335
Edition1st Edition
Right arrow
Author (1)
Houssem Yahiaoui
Houssem Yahiaoui
author image
Houssem Yahiaoui

Houssem Yahiaoui is a Telerik Developer Expert, Google Developer Group Lead, Meetup organizer, Conference Speaker, and Technical blogger among a few things. He has been a developer since the age of 14 and Firebase lover since day one. He's also a passionate JavaScript developer and strongly believes that JavaScript should fix the World's hanger problem.
Read more about Houssem Yahiaoui

Right arrow

Adding Analytics and Maximizing Earnings

In this chapter, we'll cover the following recipes:

  • Integrating Firebase analytics into Android/iOS applications
  • Implementing event logging on Android/iOS
  • Implementing user properties for data and audience filtering
  • Integrating Firebase AdMob with Android/iOS application
  • Implementing Firebase AdMob banner ads on Android/iOS
  • Implementing Firebase AdMob native ads express on Android/iOS
  • Implementing AdMob ads targeting

Introduction

Congrats! You have finished working on that new shiny application of yours. You are probably now seeking to get more information, know your user's preferences, and why not generate some money from the app as a treat for your hard work.

Firebase offers that and more. With an end-to-end analytics system, AdMob integration, and more, it is what I love to call the next pre-finished working app integration you need to manage, so you can ensure you're hearing feedback and listening to your users at least in an indirect way.

In this chapter, we're going to see how we can manage and implement analytic and AdMob campaigns within your Firebase mobile application.

Integrating Firebase analytics into Android/iOS applications

You've probably heard about Google analytics before. It's the best friend of developers and marketers when it comes to getting metrics and gathering non-intrusive data about their application's users. For a long time, having such a powerful mobile platform was a dream, but now Firebase is offering that by providing you with both a very beautiful yet very informative dashboard that you can find over at your Firebase project console. Here's how our current Android Firebase powered application will look over at Analytics:

Figure 1: Firebase Analytics based on application section.

It will hold up everything from active users, to a total awesome map showing you where your users are coming from, to even the kind of mobile devices they are using, as well as the OS version. Also, with such integration, we...

Implementing event logging on Android/iOS

Knowing that analytics start when your application starts sending basic information that you normally see on the dashboard, we can simply create another event. This would be an event that would suit our application's needs. Those analytics logs are free forever, so get creative with your logs or simply play it safe and use the Firebase default events and report them back.

Let's see how we can integrate those lovely, full of data events into our applications for both Android and iOS.

How to do it...

Let us first see how event logging is done on Android:

  1. After you've successfully installed the library in your application and selected the required activity of class where...

Implementing user properties for data and audience filtering

Suppose you want to find out people who like the new movies of Marvel or DC, or you want to discover the people who just like to eat pizza. The user properties section in your Firebase analytics section can give you up to 25 custom defined user properties.

Firebase already has some pre-predefined user properties, such as user gender, user country, and so on. You can get the list of all the predefined user properties from here: https://support.google.com/firebase/answer/6317486?hl=en&ref_topic=6317484.

Now let's define some user properties. It starts with selecting the wanted application--in my case, it's my Android application, but you can select any of the apps that use your Firebase project--and then adding the user property itself within the Firebase project console. To do so, simply head to your Project...

Integrating Firebase AdMob with Android/iOS applications

AdMob makes your mobile application profitable using nothing but plain good old ads, the integration with Firebase that also provides other services like analytics and more advanced metrics makes Firebase and AdMob the perfect mix. So in the recipes, we're going to cover how we can integrate them into Android and iOS.

How to do it...

We will first discover how to integrate Firebase AdMob within our Android application:

  1. Fire up Android Studio and open your build.gradle file. Add the following line underneath your already present dependencies:
      compile 'com.google.firebase:firebase-ads:11.0.4'
  1. Save and sync, and then, in Android Studio, go and download...

Implementing Firebase AdMob banner ads on Android/iOS

They come in different sizes, can be put in different places, and they are really easy to be implemented. AdMob Banners offer that and more; let's see how we can add AdMob banner Ads to Android/iOS applications.

Getting ready

Please follow the instructions mentioned previously, on how you can download/configure your project with Firebase AdMob on your respective platform.

How to do it...

Let us first discover how Firebase AdMob banner ads are implemented in Android.

Over Android the process is divided into two...

Implementing Firebase AdMob native ads express on Android/iOS

Whether there's a new application theme, new background, or a new event font that your shiny application both on Android or iOS can have, customizing ads to match your application is an available option. In this recipe, we're going to see how to make our application support the AdMob native ads express. So let's get to it!

Getting ready

Before we start, please follow the instructions mentioned previously on how to download/configure your project with Firebase AdMob on your respective platform.

Also before performing any coding on our application side, we will need to create the ad unit with the needed style. Remember, the native ads express lets you...

Implementing AdMob ads targeting

An application can know diversity in a user's gender, age, locations, and more. Targeting your users based on many factors can significantly improve our user experience within our application. In this recipe, we're going to see how we can add just that to our Android and iOS applications.

Getting ready

Please follow the instructions mentioned previously on how to download/configure your project with Firebase AdMob on your respective platform.

How to do it...

Let us first see how ad targeting is implemented in Android:

  1. The idea...
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Firebase Cookbook
Published in: Nov 2017Publisher: PacktISBN-13: 9781788296335
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Houssem Yahiaoui

Houssem Yahiaoui is a Telerik Developer Expert, Google Developer Group Lead, Meetup organizer, Conference Speaker, and Technical blogger among a few things. He has been a developer since the age of 14 and Firebase lover since day one. He's also a passionate JavaScript developer and strongly believes that JavaScript should fix the World's hanger problem.
Read more about Houssem Yahiaoui