Created By: Yash Nagda Last Edited: Mar 05, 2020 4:00 PM
Today marketing is essential part of the app success. Usually businesses use google or facebook ads for the marketing campaigns. But marketing alone is not enough we need a good analytics so we can understand what is working and what is not ?
success doesn't end with an install.
as this quote says we can't measure success by just looking at number of installs. We must know how many users singed up, made purchases etc. So we can fix the bottlenecks and optimise every penny that we are spending on marketing.
Facebook provide some very good set of tools for analytics. We can track our app install, sign up and purchase etc. We can also use some specific feature like funnels, target audience to track and optimise our users experience of the app. It is totally free for developer to use and facebook login is not required to use analytics.
- First visit this link and login with you facebook account.
- now give detail of your app and upload key hashes. and follow the process.
To run ads and measure installs in the Ads Manager, you are required to associate at least one Ad Account with your app.
- In the app dashboard click Settings > Advanced.
- In Authorized Ad Account IDs, add your Ad Account IDs. You can get your ad account IDs from your Ads Manager.
We can integrate Facebook analytics in our app in the following steps.
- Firstly, log in to Facebook to create apps or register as a developer.
- Now create a new android project in android studio with api 15 or higher.
- In your build.gradle (Project) file add this.
https://gist.github.com/d798a5eeaa60f984155f041da1aa89c3
- Open build.gradle (Module: app) and add following dependency.
https://gist.github.com/a2b2bd1584955d84f27855ed0574c5c8
- Now open your string.xml file and add following lines.(get the app id from facebook dashboard)
https://gist.github.com/c0f9eecc4ad86a0786555940e6fcb081
- In your AndroidManifest.xml file add a meta-data element to the application element.
https://gist.github.com/a4cebb390dd679a8cbdc4f718eff749f
- Also provide internet permission in AndroidManifest.xml file.
https://gist.github.com/bbf060f1df9051f7e45581e0272dbf1d
- Build your project.
Yay !! You have successfully integrated the facebook analytics SDK. Now you can verify this by opening the app and you will see the event on the console.
SDK will automatically record following events.
- App Installs
- App Launch
- In-App Purchases
Apart from automatic logged events we can also manually log our custom events in following steps.
- Create object of the AppEventsLogger class.
https://gist.github.com/d81e35c74070215e5889ce3e9702738a
- Now log the event.
https://gist.github.com/f93e9c5243de0acfd2567217f547e3d2
- You can also use two optional parameter in the log event method.
- Bundle - You can add a bundle and add key and value pair in it.
- valueToSum - It is a value which is summed for all the events posted by same user or different user. For example if 10 user by ₹ 10 worth items. Then this value will get summed up to ₹ 100.
https://gist.github.com/62f3f194baaa69e9d674d5dd6b4b9602
- For an example we can log an event of e-commerce app in following way.
https://gist.github.com/5cb02dfc00597f968083fff53a6b43a5
In this article we have learned how we can integrate facebook analytics in our android app. We have also learned how we can manually log our custom event to facebook analytics console. I hope you have found this article helpful. If you have any query or suggestions you can post it in the comments below or contact me at yash@gkmit.co, I will be really glad to assist you.