Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

investigate supporting GA4 #185

Closed
devoncarew opened this issue Nov 2, 2022 · 9 comments
Closed

investigate supporting GA4 #185

devoncarew opened this issue Nov 2, 2022 · 9 comments
Labels
type-enhancement A request for a change that isn't a bug

Comments

@devoncarew
Copy link
Contributor

From the google analytics docs:

all standard Universal Analytics properties will stop processing new hits on July 1, 2023

We don't yet know whether we'll support GA4 in this package or leave that to another package. If we do support it here, it's enough of a protocol change that we likely wouldn't try for backwards compatibility in the APIs; i.e. v4 of this package and v5 would have different APIs (one that matched the needs of the older measurement protocol and one that matched the needs of GA4).

This issue tracks discussing whether this package will be upgraded to support GA4 or not.

--

Notes:

@bartekpacia
Copy link

For future readers: looks like Google has shifted its focus to a https://github.com/dart-lang/tools/tree/main/pkgs/unified_analytics, which:

This package is intended to be used on Dart and Flutter related tooling only.

This is not intended to be general purpose or consumed by the community.

Does this mean that package:usage will die on July 1st, 2023?

@devoncarew
Copy link
Contributor Author

Hi @bartekpacia - yes, we have switched over to using a new package, speaking the GA4 protocol, but that's very purpose built to support the dart and flutter command line tools.

Given that, it's highly unlikely that we'll update this package to GA4 (this package was originally written to support the stagehand tool, a pre-cursor to dart create). I'll start the deprecation process for this package.

I think it's worth keeping this issue open however - I think it could be useful for people to coordinate on any replacement solutions. It's worth noting that there's not necessarily a lot of complexity in speaking to google analytics. I haven't looked at GA4 myself, but suspect (like the previous protocol) that it's not much more than just sending some well-formed http posts to a url end-point. In a web app, you might want to use js interop to wrap the existing JS library (gtag.js?). In a command-line / flutter app, you'd probably want to support some throttling and batching when actually sending the events.

@bartekpacia
Copy link

bartekpacia commented Apr 10, 2023

Thanks for answering!

I think it could be useful for people to coordinate on any replacement solutions.

Good idea :)

It's worth noting that there's not necessarily a lot of complexity in speaking to google analytics.

That's right, it's not that complex and the package isn't really necessary. In case anyone's interested, here's how we implemented basic analytics with GA4 in our CLI tool.

@mr-mmmmore
Copy link

Hey @bartekpacia, I am considering to develop my own GA4 client as you did, but it seems that the measurement protocol v4 has the required parameter app_instance_id ("This value needs to be retrieved through the Firebase SDK.") that seems to impose to have FirebaseAnalytics in the app. This is ruining my plans as my intention is to not have to add Firebase to the app.
How did you handled it? You don't seem to enforce this id as required parameter in your own client, does it work without it?

@bartekpacia
Copy link

Hi @mr-mmmmore,

I don't use app_instance_id (actually this the first time I hear about it) and everything works.

@mr-mmmmore
Copy link

OK, thanks, I'm going to try it.

@mr-mmmmore
Copy link

@bartekpacia It's working only for "web" streams, where there is a measurement_id, but ios and android streams don't have this measurement_id, the app_instance_id is required instead and must be obtained from the FirebaseAnalytics plugin :-/

@rvowles
Copy link

rvowles commented May 21, 2023

The measurement id is just the GA4 key, so it's the same as the new flutter tools. If you are using dart.io you should just http post using the GA4 key and ideally an api secret. If you are using dart.html you should proxy through the official library.

@mr-mmmmore
Copy link

I have mixed things a little bit, but the problem remains…

For an ios or android stream, any request to the measurement protocol v4 must pass api_secret and firebase_app_id as http query parameters. For a web stream the query parameters are api_secret and measurement_id. But these parameters can easily be found in the Firebase console and GA admin.
But for a mobile stream, there is an app_instance_id parameter, required in the body, and this one must be retrieved through the Firebase SDK. This is similar to the client_id for a web stream.

All this is from the measurement protocol v4 official reference, here.

So what do you mean exactly @rvowles by "The measurement id is just the GA4 key" and "the same as the new flutter tools"? Have you succesfully configured a GA4 mobile stream and sent data to it using a custom HTTP client?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type-enhancement A request for a change that isn't a bug
5 participants