Using Tag Manager Custom functions for third party events integrations

Using Tag Manager Custom functions for third party events integrations

November 17

Vodafone is a multinational telecommunications company popular in many countries. Recently they decided to expand their business to the Middle East; in the country of Oman. Our team at TunicaLabs stepped in to help them with handling their Martech.

The hurdle we came across

Handling MarTech entailed enabling customer onboarding and tracking customers' events and data. We implemented two platforms Boxever and Firebase to get the best experience. Boxever because it helps segment data according to the behaviors of users and Firebase because it manages all real-time events. But this created a brand new problem for us. Both platforms required coding but we didn't want to do the same thing twice. We found our solution in Google Tag Manager.

How GTM helped

Google Tag Manager supports tags from products such as Firebase which helps to manage events in mobile applications. When we use two platforms like Firebase and Boxever, GTM intercepts the process. So now instead of rebuilding the application, we could rely on GTM to handle it for us. All we need to do is use the Function Call to send events in Boxever using Firebase events as triggers. In simple words, a function call requests the application to provide value for a code.

Steps we followed

For the Function Call to work as it’s supposed to we need to add the appropriate code that will react to the Tag Managers request. Only then will the Tag Manager be able to provide value and take actions accordingly. The action in question for us was sending events in Boxever via GTM. We detailed out below the steps that we followed:

Step 1 - Add Google Tag Manager to your project

1.In your module Gradle file (usually app/build.gradle), add the following dependency on the Tag Manager library: pasted image 0.webp

2.Sign in to your Google Tag Manager account.

3.Select a mobile container.

4.Click Versions in the top navigation bar.

5.Click Actions > Download on the selected container version. pasted image 0 (1).webp

6.Create the app/src/main/assets/containers folder if it doesn't exist. Copy the downloaded container to the folder.

Step 2 - Add the Firebase SDK to your app

1.Using the Firebase Android BoM, declare the dependency for the Analytics Android library in your module (app-level) Gradle file (usually app/build.gradle). pasted image 0 (2).webp

2.Declare the com.google.firebase.analytics. FirebaseAnalytics object at the top of your activity: pasted image 0 (3).webp

3.Initialize it in the onCreate() method: pasted image 0 (4).webp

4.Start logging events pasted image 0 (5).webp

Step 3 - Custom Tag Provider Class

1.Import your GTM container

2.Implement a class that extends com.google.android.gms. tagmanager.CustomTagProvider. Please see an example below : pasted image 0 (6).webp

3.Within this custom class, use the following function below public abstract void execute (Map<String, Object> parameters)

4.Within this function, read the parameters passed by GTM within the "execute" function and send event to Boxever pasted image 0 (7).webp

Step 4 - GTM Tag Configuration

1.Create a new Tag under Tags section and provide a name a.Click on Tag Configuration and under Tag type select Function Call. b.Provide the created classpath under the Class path section pasted image 0 (8).webp

2.Click on Triggering section and choose your appropriate trigger on which this Tag should fire, in our case its search_event pasted image 0 (9).png

Our goal was to send events in Boxever via moving them through Firebase tagging. With Google Tag Manager we were able to do that. We reused Firebase tagging while also avoiding duplicate work for Boxever events.

View Previous Blog

Previous

View Next Blog

Next