#GTMTips: Use Product-scoped Custom Dimensions In GA Firebase
Thanks to the intrepid detective work of Jørn Reidel and Ahmed Marof, it looks like one of the big hurdles for doing a full migration from using the legacy Google Analytics and Google Tag Manager SDKs to the latest Tag Manager + Firebase SDK is now a non-issue.
The issue is, of course, Product-scoped Custom Dimensions or more specifically the lack of support thereof. Until now, I’d been holding against recommending the migration to anyone with Enhanced Ecommerce tracking set up simply because the documentation didn’t mention the possibility of sending these custom definitions to Google Analytics.
But, Jørn Reidel did what anyone who wants to actually find the truth beyond documentation should have done: he tested different ways to do it, and found the solution. Spoiler alert: it’s quite logical.
Tip 93: Send Product-scoped Custom Dimensions with Firebase
Naturally, this applies to the “legacy” Universal Analytics tags in Firebase GTM only. Google Analytics for Firebase doesn’t have a model for Enhanced Ecommerce any more. Also, thanks to the recent news about the upcoming deprecation of Google Analytics for mobile apps, this tip is probably short-lived.
Anyway, the simple solution is to do what you’d do with the
dataLayer setup when working with Enhanced Ecommerce for Google Tag Manager on the web: you hard-code the dimension and metric indices into the item bundles themselves.
This is what it would look like with Swift (iOS):
let product1: [String : Any] = [ AnalyticsParameterItemID: "sku1234", AnalyticsParameterItemName: "Donut Friday Scented T-Shirt", AnalyticsParameterItemCategory: "Apparel/Men/Shirts", AnalyticsParameterItemVariant: "Blue", AnalyticsParameterItemBrand: "Google", AnalyticsParameterPrice: 29.99, AnalyticsParameterCurrency: "USD", AnalyticsParameterQuantity: 1, "dimension4": "Product Scoped Value 01 - GTM Firebase" ]
And the same in Kotlin (Android):
val product1 = Bundle() product1.putString(FirebaseAnalytics.Param.ITEM_ID, "sku1234") product1.putString(FirebaseAnalytics.Param.ITEM_NAME, "Donut Friday Scented T-Shirt") product1.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "Apparel/Men/Shirts") product1.putString(FirebaseAnalytics.Param.ITEM_VARIANT, "Blue") product1.putString(FirebaseAnalytics.Param.ITEM_BRAND, "Google") product1.putDouble(FirebaseAnalyitcs.Param.PRICE, 29.99) product1.putString(FirebaseAnalytics.Param.CURRENCY, "USD") product1.putLong(FirebaseAnalytics.Param.QUANTITY, 1) product1.putString("dimension4", "Product Scoped Value 01 - GTM Firebase")
If done correctly (i.e. you have a tag firing in GTM that sends the Enhanced Ecommerce data to Google Analytics), you should see your Custom Dimension surface when queried against this product with the Ecommerce action it was sent in.
Simple solution to a jarring problem. Thank you Jørn and Ahmed for the detective work!