Closed muccy closed 9 months ago
/cc @russellwheatley for visibility.
any update?
Are you able to prove that a list shows up in the Firebase console? My investigation showed that they do not, and the Firebase documentation is pretty clear on that as noted in the PR.
Yes, I am.
In the current version of the app I'm using firebase_analytics: 10.1.0
and I'm not using the library events in order to track (for instance) purchases. I'm calling something like:
await FirebaseAnalytics.instance.logEvent(
name: "purchase",
parameters: {
"items": data.products
.map(
(product) => {
"item_id": product.id,
"item_name": product.name,
"price": product.price.value,
"currency": product.price.currency.code,
"quantity": product.quantity,
},
)
.toList(),
"value": data.grandTotal.value,
"currency": data.grandTotal.currency.code,
"transaction_id": data.transactionId,
"shipping": data.shippingCost.value,
if (data.couponCode?.isNotEmpty == true) "coupon": data.couponCode,
if (data.firstMargin != null) "tnc_first_margin": data.firstMargin?.value,
if (data.secondMargin != null) "tnc_second_margin": data.secondMargin?.value,
},
);
I can confirm you I can see data incoming to GA4:
I would be more than happy using stock methods (e.g. logPurchase) but, as you can see, I need to pass extra data along with the event (e.g. tnc_first_margin
).
On the other hand, it would not be a problem also to keep using logEvent
manually if there was a way to circumvent the assertion
Are you able to prove that a list shows up in the Firebase console? My investigation showed that they do not, and the Firebase documentation is pretty clear on that as noted in the PR.
It is also possible to add custom parameters to items, not just events. Interestingly Firebase documentation also has a Dart/Flutter code sample which is not possible with this plugin!
https://firebase.google.com/docs/analytics/measure-ecommerce#item_custom_parameters
The linked pull request works pretty well in production. Sadly I'm still searching the time to fill the checklist
@muccy do you need help?
Hello!
My name is Fabricio, I'm part of the technology team at i-Cherry, a Google partner agency and official reseller of Google Analytics, and as an official partner we provide support to customers not only in implementation but in solving problems involving Analytics.
Recently, our customers with flutter applications that use this plugin are having problems logging Ecommerce events with additional custom parameters. In one of them, a migration from React Native to Flutter is being made, and unfortunately the implementation that is now functional in React Nactive cannot be replicated in Flutter due to the limitation imposed where it is not possible to send the array items (for ecommerce events) in the logEvent and it is also not possible to send additional parameters in preconfigured ecommerce events, this limits some implementations that need additional data which can vary greatly from client to client.
As @muccy mentioned an example of a purchase with additional parameters, this type of situation is very common, of needing to enrich the data with specific information about the customer's business, but with the current limitations placed, it is impossible to apply them in a friendly way.
A very common practice among the clients we serve is the implementation of customized modules (classes) to centralize analytics tools in order to be reused in every application, and normally "logEvent" is used for its freedom to define the event and parameters according to need.
I understand that the limitation has been implemented because arrays are not allowed in custom events, resulting in error 21 in firebase, but even with this error the information is recorded, discarding only the error, but it will not be an error if the event name is an expected standard event according to the official Google documentation (purchase, add_to_cart and others from ecommerce).
Please, I ask you to review, at least the logEvent and leave it free for customization as needed, as I understand that this should be his proposal, removing the limitation that today only the flutter version of the SDK has.
It is worth mentioning that GA4 (the current version of Google Analytics) is constantly evolving, and frequently receives relevant updates on events, and I understand that logEvent with less restrictions will allow the use of new features in the future to be used without the need for an update in the Flutter SDK code, as it is in the Java and Swift SDK.
Hey @mvolpato, this morning I finally found the time to complete the PR checklist. Any help or opinion is great anyway. For example I keep having problems with melos + cloud_firestore_odm_generator
. In fact I had to ignore it when bootstrapping
Hey @mvolpato, this morning I finally found the time to complete the PR checklist. Any help or opinion is great anyway. For example I keep having problems with melos +
cloud_firestore_odm_generator
. In fact I had to ignore it when bootstrapping
I do not know much about cloud_firestore_odm_generator
. I was volunteering for getting the PR to the state that it is now. Thanks for updating it.
Thanks for the feedback, I'll take a look at this once I get a chance 🙏
Hello @russellwheatley, have you had a chance to give the PR a look?
Hi @russellwheatley , is there any way we can increase visibility of this issue?
Sorry for the tardiness on this issue, the PR LGTM.
For future reference, custom parameters can be sent with any event as documented here.
Custom parameters can also be sent with Items
as documented here.
Let me raise this with the Firebase team and, should they approve, I will look to get this merged. Thank you for your patience 🙏
Bug report
Describe the bug The version 10.1 of
firebase_analytics
plugin introduced an assertion to filter out lists from custom parameters (see: https://github.com/firebase/flutterfire/pull/9520). This change forces us to use stock methods (e.g.:logPurchase
) in order to track e-commerce events but we are not allowed to pass extra (legal) parameters to GA4.Expected behavior
To circumvent the restrictions of the stock methods I used to call
logEvent
with the proper event name and parameter keys.It should be useful to enrich stock
log*
methods with extra parameters to pass.