firebase / firebase-android-sdk

Firebase Android SDK
https://firebase.google.com
Apache License 2.0
2.26k stars 572 forks source link

Issues with Promo impressions and clicks (for Universal Analytics) on SDK version 17.5.0 #2075

Closed rafael-tolentino closed 2 years ago

rafael-tolentino commented 3 years ago

[READ] Step 1: Are you in the right place?

Issues filed here should be about bugs in the code in this repository. If you have a general question, need help debugging, or fall into some other category use one of these other channels:

[REQUIRED] Step 2: Describe your environment

[REQUIRED] Step 3: Describe the problem

I'm trying to implement promotion impression on my app, following Google's documentation for enhanced e-commerce on GTM for android:

GTM Android Ecommerce Documentation

But I've encountered issues with promo impressions and promo clicks.

When I was using the 17.2.2 version of the Firebase SDK, everything worked as expected, I was able to send the events and get them to appear on my App view from Google Analytics (Universal Analytics)

But, when I upgraded to the SDK version 17.5.0, I got an error when trying to log the promo view and promo click events.

I'm getting error code 20 for view_item event, saying that the "promotions" name is invalid

Firebase error codes

I'm following the documentation provided, but I keep getting this error with SDK version 17.5.0, but not with SDK version 17.2.2

I've also tried the new e-commerce events for firebase, but it only worked in the app+web property, even though I've created a tag for this event on GTM.

Firebase ecommerce events documentation

Here are the event logs with SDK version 17.2.2

2020-10-19 10:55:58.501 3197-6365/? V/FA-SVC: Logging event: origin=auto,name=screen_view(_vs),params=Bundle[{ga_event_origin(_o)=auto, ga_screen_class(_sc)=MainActivity, ga_screen_id(_si)=659629347600366262}]
2020-10-19 10:55:58.507 3197-6365/? V/FA-SVC: Upload scheduled in approximately ms: 3207608
2020-10-19 10:55:58.507 3197-6365/? V/FA-SVC: Unscheduling upload
2020-10-19 10:55:58.509 3197-6365/? V/FA-SVC: Scheduling upload, millis: 3207608
2020-10-19 10:55:58.513 3197-6365/? V/FA-SVC: Background event processing time, ms: 12
2020-10-19 10:55:58.587 3197-6365/? V/FA-SVC: Logging event: origin=app+gtm,name=view_item,params=Bundle[{ga_event_origin(_o)=app+gtm, ga_screen_class(_sc)=MainActivity, ga_screen_id(_si)=659629347600366262, ga_event_id(_eid)=9104534382376520303, ga_extra_params_ct(_epc)=1, promotions=1}]
2020-10-19 10:55:58.594 3197-6365/? V/FA-SVC: Upload scheduled in approximately ms: 3207521
2020-10-19 10:55:58.594 3197-6365/? V/FA-SVC: Unscheduling upload
2020-10-19 10:55:58.595 3197-6365/? V/FA-SVC: Scheduling upload, millis: 3207521
2020-10-19 10:55:58.598 3197-6365/? V/FA-SVC: Background event processing time, ms: 12
2020-10-19 10:55:58.601 3197-6365/? V/FA-SVC: Logging event: origin=app+gtm,name=ga_extra_parameter(_ep),params=Bundle[{item_name=Summer Sale, creative_name=summer_banner2, creative_slot=banner_slot1, ga_index(_i)=0, ga_event_origin(_o)=app+gtm, ga_event_name(_en)=view_item, ga_group_name(_gn)=promotions, ga_list_length(_ll)=1, ga_screen_class(_sc)=MainActivity, ga_screen_id(_si)=659629347600366262, ga_event_id(_eid)=9104534382376520303, item_id=PROMO_1234}]
2020-10-19 10:55:58.606 3197-6365/? V/FA-SVC: Upload scheduled in approximately ms: 3207509
2020-10-19 10:55:58.606 3197-6365/? V/FA-SVC: Unscheduling upload
2020-10-19 10:55:58.607 3197-6365/? V/FA-SVC: Scheduling upload, millis: 3207509
2020-10-19 10:55:58.612 3197-6365/? V/FA-SVC: Background event processing time, ms: 10
2020-10-19 10:55:58.616 3197-6365/? V/FA-SVC: Logging event: origin=app+gtm,name=screenview,params=Bundle[{screen_name=demo app home, ga_event_origin(_o)=app+gtm, ga_screen_class(_sc)=MainActivity, ga_screen_id(_si)=659629347600366262, is_debug=true}]
2020-10-19 10:55:58.620 3197-6365/? V/FA-SVC: Upload scheduled in approximately ms: 3207495
2020-10-19 10:55:58.620 3197-6365/? V/FA-SVC: Unscheduling upload
2020-10-19 10:55:58.622 3197-6365/? V/FA-SVC: Scheduling upload, millis: 3207495
2020-10-19 10:55:58.626 3197-6365/? V/FA-SVC: Background event processing time, ms: 11

And the event log with SDK version 17.5.0 (it is the same event, the only change was the SDK version)


2020-10-19 11:01:53.780 3197-7520/? V/FA-SVC: Logging event: origin=app,name=view_item,params=Bundle[{ga_event_origin(_o)=app, ga_error_value(_ev)=promotions, ga_error(_err)=20}]
2020-10-19 11:01:53.782 3197-7520/? V/FA-SVC: Upload scheduled in approximately ms: 2852333
2020-10-19 11:01:53.782 3197-7520/? V/FA-SVC: Unscheduling upload
2020-10-19 11:01:53.783 3197-7520/? V/FA-SVC: Scheduling upload, millis: 2852333
2020-10-19 11:01:53.790 3197-7520/? V/FA-SVC: Background event processing time, ms: 10
2020-10-19 11:01:53.792 3197-7520/? V/FA-SVC: Logging event: origin=app,name=screenview,params=Bundle[{screen_name=demo app home, ga_event_origin(_o)=app, is_debug=true}]
2020-10-19 11:01:53.795 3197-7520/? V/FA-SVC: Upload scheduled in approximately ms: 2852320
2020-10-19 11:01:53.795 3197-7520/? V/FA-SVC: Unscheduling upload
2020-10-19 11:01:53.796 3197-7520/? V/FA-SVC: Scheduling upload, millis: 2852320
2020-10-19 11:01:53.800 3197-7520/? V/FA-SVC: Background event processing time, ms: 7
2020-10-19 11:01:53.801 3197-7520/? V/FA-SVC: Logging event: origin=auto,name=screen_view(_vs),params=Bundle[{ga_event_origin(_o)=auto, ga_screen_class(_sc)=MainActivity, ga_screen_id(_si)=1530670941200468227}]
2020-10-19 11:01:53.806 3197-7520/? V/FA-SVC: Upload scheduled in approximately ms: 2852309
2020-10-19 11:01:53.806 3197-7520/? V/FA-SVC: Unscheduling upload
2020-10-19 11:01:53.808 3197-7520/? V/FA-SVC: Scheduling upload, millis: 2852309
2020-10-19 11:01:53.810 3197-7520/? V/FA-SVC: Background event processing time, ms: 9
2020-10-19 11:01:53.813 3197-7520/? V/FA-SVC: Saving default event parameters, appId, data size: com.example.myapplication, 2
2020-10-19 11:01:58.837 7613-7687/com.example.myapplication V/FA: Inactivity, disconnecting from the service

Relevant Code:

Here's the part of the code that I'm using:


// Define promotion with relevant parameters

Bundle promotion = new Bundle();
promotion.putString( Param.ITEM_ID, "PROMO_1234" ); // promotion ID; either ITEM_ID or ITEM_NAME is required
promotion.putString( Param.ITEM_NAME, "Summer Sale" ); // promotion name
promotion.putString( Param.CREATIVE_NAME, "summer_banner2" );
promotion.putString( Param.CREATIVE_SLOT, "banner_slot1" );

// Prepare ecommerce bundle

ArrayList promotions = new ArrayList();
promotions.add(promotion);

Bundle ecommerceBundle = new Bundle();
ecommerceBundle.putParcelableArrayList("promotions", promotions );

// Log view_item, view_item_list, or view_search_results event with ecommerce bundle

mFirebaseAnalytics.logEvent(Event.VIEW_ITEM, ecommerceBundle );  

If any other information is needed, please let me know.

Thanks

google-oss-bot commented 3 years ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

vkryachko commented 3 years ago

@g-charbel ptal

mmtwg commented 3 years ago

Hi there Any updates on this issue?

vkryachko commented 3 years ago

The latest version of analytics is 18.0.1, are you having this problem with it?

google-oss-bot commented 3 years ago

Hey @rafael-tolentino. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

mmtwg commented 3 years ago

I believe the issue here is that "items" should be used as the key for the items instead of "promotions".

rafael-tolentino commented 3 years ago

Sorry for the late reply.

I'm testing now using:

implementation platform('com.google.firebase:firebase-bom:26.4.0')
implementation 'com.google.firebase:firebase-analytics'

And doing the exact implementation as described on the google tag manager documentation for enhanced e-commerce:

documentation

I'm still having the same issues.

@mmtwg Using "items" as the name leads to another error on firebase. (gives error 25)

debugview image debugview image 2

firebase error code 25 description

This error is rather odd, but I'm testing with this play services version:

classpath 'com.google.gms:google-services:4.3.5'

mgiordano commented 3 years ago

Even if using "items" as the param key worked at the Firebase level, GTM will not be able to translate that into a promotions payload for Universal Analytics enhanced ecommerce. The bigger problem is that GTM SDK has not been updated to support the new GA4 ecommerce schema, so if you want to keep sending ecommerce info to UA you're forced to stick with this old Firebase setup which evidently is not being supported by SDK updates and thus is now broken for this case (or deprecated for the legacy "ecommerce_purchase" event that GTM expects). Best solution: Tag Manager needs to support new Firebase schema, not the other way around. That way you can have GA4 ecommerce data and keep that translated into UA.

rafael-tolentino commented 3 years ago

@mgiordano So right now is not possible to use Promo impressions and clicks for UA if you are on a Firebase Analytics version higher than 17.5.0, and GTM is not able to interpret the structure of the new firebase events for e-commerce.

Is there a place where I can address the GTM team about this issue?

connected-acaragheorghii commented 3 years ago

Hi, I am having he same issue with promotions in view_item and select_content events Getting: firebase_error: 20 error_value: promotions

Using com.google.firebase:firebase-bom:26.8.0

When I downgrade to com.google.firebase:firebase-bom:25.11.0 which has firebase-analytics version 17.5.0 its working

Any idea when this will be fixed or if there is workaround ?

fredlifeup commented 2 years ago

Even if using "items" as the param key worked at the Firebase level, GTM will not be able to translate that into a promotions payload for Universal Analytics enhanced ecommerce. The bigger problem is that GTM SDK has not been updated to support the new GA4 ecommerce schema, so if you want to keep sending ecommerce info to UA you're forced to stick with this old Firebase setup which evidently is not being supported by SDK updates and thus is now broken for this case (or deprecated for the legacy "ecommerce_purchase" event that GTM expects). Best solution: Tag Manager needs to support new Firebase schema, not the other way around. That way you can have GA4 ecommerce data and keep that translated into UA.

@mgiordano thank you for providing this.

Hi, we also having the similar issue on our project. Anybody know when this will be fixed? Thanks.

aguatno commented 2 years ago

Hi @rafael-tolentino sorry that it's taking this long. I've tried the latest SDK of Firebase Analytics 19.0.2 and it seems I was able to see the log of VIEW_ITEM event without issues. Here's the code snippet or you may visit our documentation for more details. cF6LGBjg9GyADcE

I'd recommend using the latest SDK version in your app to ensure old known bugs are fixed. Let me know if the issue persists.

fredlifeup commented 2 years ago

Hi @aguatno could you add a custom dimension property in the last line and see the result in the debug view? Thanks.

val itemJeggings = Bundle().apply {
    putString(FirebaseAnalytics.Param.ITEM_ID, "SKU_123")
    putString(FirebaseAnalytics.Param.ITEM_NAME, "jeggings")
    putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "pants")
    putString(FirebaseAnalytics.Param.ITEM_VARIANT, "black")
    putString(FirebaseAnalytics.Param.ITEM_BRAND, "Google")
    putDouble(FirebaseAnalytics.Param.PRICE, 9.99)
    putString("customDimension1", "custom_value")
}
aguatno commented 2 years ago

Hi @fredchenww here's the result. bvjk84JC4uuqBRJ

fredlifeup commented 2 years ago

Hi @aguatno, it seems you put the custom dimension in the promoParams variable, not the itemJeggings variable. I think they are different level. Could you check the code I showed above. Thanks.

google-oss-bot commented 2 years ago

Hey @rafael-tolentino. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot commented 2 years ago

Since there haven't been any recent updates here, I am going to close this issue.

@rafael-tolentino if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.