How to integrate Google tag manager + Firebase into cordova app?

I am trying to integrate google tag manager into my Cordova based project. The firebase integration was easy because there is a plugin that manages firebase https://github.com/arnesson/cordova-plugin-firebase

All guides from Google are for native apps, not mashups. Integrating a tag manager in a mashup seems like a question with no good answer so far, because if you try to treat the app as a webview it will give you errors in most cases.

Any suggestions on how to integrate Google Tag Manager into a hybrid app?

Thank.

+3


source to share


1 answer


Actually your plugin supports google tag manager but only for android. As far as I know this is not "officially" supported by your plugin.

Here is your ssh manager for google-tag-sdk for android in your plugin

Set up your google tag manager with an android container (important) then upload your json file and add the resource file path to your config.xml.

<platform name="android">
        <content src="index.html" />
        <resource-file src="resources/android/containers/GTM-5MFXXXX.json" target="assets/containers/GTM-5MFXXXX.json" />

      

here is its documentation . Yes, I know that no more

Finish creating your app with cordova if the json file is in the correct folder.



root
- src
- node_modules
- platform
---- Android
------ assets
-------- img
-------- containers
----------> gtm. json
---- etc

If you want your google tag manager to work, then start your Android Studio debugger and check the logs with logcat.

You should see something like this.

16:01:03.742 9748-9776/XXX I/GoogleTagManager: Loading container GTM-XXXXXX
16:01:03.750 9748-9776/XXX I/GoogleTagManager: Installing Tag Manager event handler.
16:01:03.757 9748-9776/XXX I/GoogleTagManager: Tag Manager event handler installed.
16:01:03.757 9748-9776/XXX I/GoogleTagManager: Tag Manager initilization took 28ms
16:01:05.502 9748-9882/XXX I/GoogleTagManager: Obtained fresh AdvertisingId info from GmsCore.

      

Your firebase sdk does the rest! This should make everything work

+1


source







All Articles