How to set up Facebook analytics in Google Tag Manager for Android
Asked Answered
I

1

7

I am using Google Tag Manager for sending analytics to various channels like Google Analytics. Now I want to send analytics to Facebook as well but I could not find any way to do so.

PS: The question is for Android app not for website. I had found multiple ways to send events to Facebook for website like: https://www.advertisemint.com/install-facebook-pixel-google-tag-manager/

I have tried to do so for Android Container as well but it does not have CustomHtml option while creating Tag. I think their might be some different approach for this.

Illuminometer answered 29/8, 2017 at 10:42 Comment(0)
B
9

If you want to use GTM in order to send events to FB analytics, you'll have to select "function call" when creating your tag in GTM. At this time, you'll have to populate the key-value pairs that you want to be in the payload your app will receive. You'll also have to reference a class which will handle this tag. This class will implement from com.google.android.gms.tagmanager.CustomTagProvider. Here is how a simple tag looks like in our GTM interface : simple FB tag for GTM

I helped to develop a connector called Cargo for my company, which helps to collect analytics through different platforms on mobile apps. Do not hesitate to take a look at it, or even to adopt it, and to pull some changes if you want to ! :)

  1. Here is our class Tags which handles the custom function calls set in GTM.
  2. Then we route the call to the selected handler/connector, depending on a parameter in the payload given by the container. This method does the job.
  3. Last, but not least, we route the call to the correct method of the selected handler/connector, which receives the payload with all the parameters you set in your GTM interface.

I hope this helps !

Boogiewoogie answered 8/9, 2017 at 13:52 Comment(2)
Thx @Boogiewoogie for this answer. Btw, it's possible for you to share a really base example using CustomTagProvider, how to call/use it and firing triggers rule?Seadog
Hi @Seadog ! The CustomTagProvider is used in the class Tags mentionned in my answer above. Your class has to implement it. Then you create an execute method with a Map<String, Object> as parameters. These parameters are basically the one that are given in the GTM interface : in the example above the keys are eventName and handlerMethod. All you have to do is to lead these arguments to the right part of your code to give them as parameters to the Analytics tool of your choice. Do not hesitate to read through the code I provided in my answer, you should understand the whole process easilyBoogiewoogie

© 2022 - 2024 — McMap. All rights reserved.