If you work with Android Apps, you know for a fact that there are situations where you might want to add multiple Google Tag Manager (GTM) containers. One of our clients was in this very situation and an added problem that they were facing was that their GTM container was full.
We were now facing a situation where we had to remove the extra tags and triggers, but this fixed the problem only for a short time. Hence, my team and I were determined to find a long-term solution for this which could be helpful for other clients and Google Tag Manager users like you as well. We started off by trying to add multiple Google Tag Manager containers at once, and guess what? It worked like magic!
This blog post is an ultimate guide that’ll help you add multiple containers inside your Android Application.
I assume that you already have one Google Tag Manager container installed as per How to implement Google Tag Manager for Android.
To add the second container, follow the below three steps:
1. Download the binary file from new Google Tag Manager container as below:
Inside GTM, Go to Versions tab-> Action -> Download.
Image 1: Downloading the binary file from new GTM container
2. Add the downloaded file to the raw folder.
Image 2: Adding downloaded file to raw folder
3. Create an object of PendingResult with new Google Tag Manager id and call setResultCallBack in your Application Class.
Image 3: Creating an object of PendingResult
Now, you can get the following DataLayer Singleton anywhere in the application :
Make sure that you use same Data Layer object across your Application.
Now you can push any dataLayer event for both the containers. The only thing you need to take care of, is to check whether both the containers do not contain the same tags. If that’s the case, then, 2 similar tags will be fired even though you push the event only once.
In 3 simple steps, you will be ready to use the second container for tracking the events. When compared to web, app implementation is simpler since you do not need to add the new container snippet on all the screens.
We hope this blog post proved to be a useful guide to you. We would love to hear from you if you have any feedback for us or even if there are any workarounds that you might have derived. Tell us all about it in the comment section below.
Click here to know more about our Google Analytics Audit Solutions. Feel free to reach out to us in case of you need any assistance with Google Tag Manager.
Latest posts by Sameer Sanghavi (see all)
- Facebook Ads Install Data Missing in Google Analytics? We are at your rescue - January 19, 2018
- Migrate your website to new host for enhanced Google Analytics Tracking - December 29, 2017
- Google Analytics Real Time Data in Google Sheet - December 23, 2017