I am working on an Android e-commerce application and I would like to track advanced e-commerce events in Google Analytics through GTM v5 (included in the Firebase SDK).
To do this, in order to send an "impressions" event, I am trying to convert the old datalayer into a package object accepted by GTM v5 with the Firebase SDK.
So the next datalayer
DataLayer.mapOf( "currencyCode", "EUR", // Local currency is optional. "impressions", DataLayer.listOf( DataLayer.mapOf( "name", produitsDispo.get(0).name, // Name or ID is required. "id", produitsDispo.get(0).sku, "price", produitsDispo.get(0).price, "brand", produitsDispo.get(0).brand, "category", produitsDispo.get(0).category, "variant", produitsDispo.get(0).variant, "list", produitsDispo.get(0).category, "position", 1), DataLayer.mapOf( "name", produitsDispo.get(1).name, "id", produitsDispo.get(1).sku, "price", produitsDispo.get(1).price, "brand", produitsDispo.get(1).brand, "category", produitsDispo.get(1).category, "variant", produitsDispo.get(1).variant, "list", produitsDispo.get(1).category, "position", 2), DataLayer.mapOf( "name", produitsDispo.get(2).name, "id", produitsDispo.get(2).sku, "price", produitsDispo.get(2).price, "brand", produitsDispo.get(2).brand, "category", produitsDispo.get(2).category, "variant", produitsDispo.get(2).variant, "list", produitsDispo.get(2).category, "position", 3)));
Now:
Bundle myBundle = new Bundle(); myBundle.putString("currencyCode", "EUR"); myBundle.putParcelableArrayList("impressions", constructBundleImpressions(produitsDispo)); mFirebaseAnalytics.logEvent("ecommerce", myBundle); public ArrayList<Bundle> constructBundleImpressions(ArrayList<Item> produitsDispo){ ArrayList<Bundle> bundleImpressions = new ArrayList<Bundle>(); Bundle tempBundle = new Bundle(); for (int i=0; i<produitsDispo.size();i++){ tempBundle.clear(); tempBundle.putString("name", produitsDispo.get(i).name); Log.d("AAAAA ; ", produitsDispo.get(i).name); tempBundle.putString("id", produitsDispo.get(i).sku); tempBundle.putString("price", produitsDispo.get(i).price.toString()); tempBundle.putString("brand", produitsDispo.get(i).brand); tempBundle.putString("category", produitsDispo.get(i).category); tempBundle.putString("variant", produitsDispo.get(i).variant); tempBundle.putString("list", produitsDispo.get(i).category); tempBundle.putInt("position", i+1); bundleImpressions.add(tempBundle); }
I already set up a GTM container with a value, trigger, and tag, but this hit does not appear on the Google Analytics toolbar.
I think the problem arises because Firebase does not accept a complex package for events, so even if it is correct, the package with ArrayList is not interpreted by the Firebase event log.
How do you feel about this? Have you ever encountered this problem?