capacitor-community / firebase-analytics

Enable Firebase Analytics for Capacitor Apps
MIT License
160 stars 64 forks source link

[QUESTION] How to make UTM parameters working when native? #117

Closed sneko closed 2 years ago

sneko commented 2 years ago

Hi,

Since there is no section for questions I post it here:

UTM parameters are fully working when dealing with a web version (with Google Analytics...), but when it comes to a native application and since GA4 no longer work into hybrid app (due to checkProtocolTask no longer available to be overridden) we have to use Firebase Analytics.

From what I see the only way to keep track of UTM parameters across installation and even when opening the app is to use Firebase Dynamic Links (another product) specifying UTM parameters in the original URL.

That's a solution but I won't be able to generate dynamic links everywhere a link to my app needs to be posted. I would like the universal links (~= deep links) to be working too so when doing: https://example.com?utm_source=sneko or even example://?utm_source=sneko

... it should report to Firebase Analytics properly. But from what I see it does not work. I could try to parse manually the parameters once in my JavaScript, but I don't know which method to call on the Firebase side to properly says it's UTM parameters πŸ˜„

Any thought on this? Maybe I miss something that could help.

Thank you,

EinfachHans commented 2 years ago

@sneko did you ever find a solution? πŸ˜ƒ

sneko commented 2 years ago

@EinfachHans unfortunately it seems there is no solution... See https://github.com/firebase/firebase-ios-sdk/issues/9817

The only thing is to have a Firebase Dynamic Link built with the UTM parameters to populate Google Analytics (if another tool... you are stuck). Those links need to be formatted everywhere you post it. When you think about it it's impossible your marketing team will do it correctly all the time... Also when it's a posted link by a visitor, the link won't be formatted.

Consider it as not doable (so closing the issue).

(on the other side I made a tiny library https://github.com/sneko/hyperlink-middleware to format frontend links when they are clicked (e.g. on landing page, blogs...). I use it to format universal links only when raw links are clicked (it avoids developers/marketers to handle the complexity when writing a hard-coded link). It centralizes a bit the build process that is always really techy most of the time. It won't apply to websites that does not set the library+middlewares for your links, but anyway it's really unlikely third-parties websites would deal with your Firebase Dynamic Links (except Ad platforms, but in this case you can format them properly once when creating the Ad campaign)

EinfachHans commented 2 years ago

Just checked the firebase sdk itself, looks like they just take the parameters and add them as parameters to a analytics event πŸ€”