I try to create a simple custom tag for catching "purchase" events from Firebase Analytics. My tag config is below.
Tag Type : Function Call
ClassPath : com.xx.xx.GTMProvider
Key - Value
items - {{Items-Custom}}
action_type - FBevent
class_name - NmEventPurchase
{{Items-Custom}} is for the key "items" which was added in Variables section.
The problem is whenever I trigger the code below;
Bundle params = new Bundle();
Bundle item1 = new Bundle();
item1.putString(FirebaseAnalytics.Param.ITEM_ID, "ABCD123");
item1.putString(FirebaseAnalytics.Param.ITEM_NAME, "jeggings");
item1.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "pants");
Bundle item2 = new Bundle();
item2.putString(FirebaseAnalytics.Param.ITEM_ID, "1234");
item2.putString(FirebaseAnalytics.Param.ITEM_NAME, "boots");
item2.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "shoes");
Parcelable[] products = new Parcelable[]{item1,item2};
params.putParcelableArray("items",products);
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.PURCHASE, params);
I got the error below;
E/GoogleTagManager: Internal error - Function call: __md_main Type not supported: class [Landroid.os.Parcelable;
If I just send a string (for example json string) instead of parcelable[] for the items param, everything is just working fine. I need to findout how to add a custom variable which contains a mixed array type in GTM Console.
I am really stuck at this point and there is no any explanations about the issue. Any help would be highly appreciated.
PS: Tag Manager Android dependency : 'com.google.android.gms:play-services-tagmanager:17.0.0'
Thank you all..
first of all and just for consistency, where you put your items into the bundle your should use params.putParcelableArray(FirebaseAnalytics.Param.ITEMS, products);
instead of: params.putParcelableArray("items",products);
I need to findout how to add a custom variable which contains a mixed array type in GTM Console.
Unfortunately in enhanced ecommerce you cannot add custom parameters to your bundles.
About your error, you should be using ArrayList instead of Parcelable. Take a look at the documentation. It should look something like this:
ArrayList items = new ArrayList();
items.add(item1);
items.add(item2);
params.putParcelableArrayList(FirebaseAnalytics.Param.ITEMS, items );
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.PURCHASE, params);