Enhanced Ecommerce: Google Tag Manager + Firebase

erkutaras
Trendyol Tech
Published in
5 min readJun 5, 2018

During my carrier, I worked for different companies which are in different sectors like finance, hotels bookings, banking, investment, education, etc. And also during this period, I developed and managed lots of projects. When developing and maintaining the applications, I have tried to keep architecture and design of the applications up-to-date like all developers. In addition, there are always somebody who works as marketing/sales people, product managers/owners or anybody that wants to measure something in the applications. To make something measurable in an application, I and you have to add a lot of events’ codes in our application codes that we try to keep up-to-date as a developer. These codes usually affect your architecture, clean codes and damage your structure. Despite all damages, I have learnt importance of the measurements at least when I was part of development team of Trendyol which is e-commerce company and continues to sales in Turkey.

“I’m sorry to say that: We have to add these code blocks to our application and measure our user’s behavior and also increase our conversion rates.”

In this article, I don’t mention how to prevent these affects. (Perhaps, I will write something about what we try to protect our architecture in Trendyol next days.) The main topic of the article is what Enhanced Ecommerce is and how we can implement it to Android application. So, let’s begin…

What is Enhanced Ecommerce?

Enhanced Ecommerce is a term which is named by Google to measure user interaction when shopping experience with Google Tag Manager and different products like Firebase Analytics, AdWords, Adjust, etc.

Google Tag Manager supports following products:

Firebase Analytics, Google Analytics, DoubleClick, AdWords, Adjust, AppsFlyer, Apsalar, Kochava, Tune, Custom Function Calls (for other products)

Google Tag Manager enables developers to measure tags and pixels in mobile applications or web sites easily. When you implement Tag Manager, you can measure specific user interaction like product impression, adding item to basket, clicking promotion, etc. without rebuild and new deployment.

As a developer, we have to know that these interactions are specialized for shopping flow and purchasing behavior of users. However, the specialized events provide us deep-measurement about user interaction. You can find these specialized events following list and next part, I will show how to send the events in Android application:

Product impressions, Product clicks/selections, Product detail views, Additions to cart, Removals from cart, Promotion impressions, Promotion clicks/selections, Checkout process, Purchases, Refunds

Implementation for Android Application

  1. Add Tag Manager and Firebase dependencies to build.gradle of your project. (SDK version must be 11 or higher.)

2. Create Tag Manager Container (I skip this step, because as a developer, we have a container that is provided from someone who follow these measured datas. If you want to create the container, you can read Tag Manager Help documentation.)

3. Implement any specialized event that you want to measure. (Following product models will be used in all events as product1, product2 and promotion.)

  • Product impressions

To measure product impressions on list, you can add one more products in bundle to ArrayList and log event with Event.VIEW_SEARCH_RESULTS key.

  • Product clicks/selections

Same as product impressions except adding second product to list bundle and log key. You can send event with Event.SELECT_CONTENT.

  • Product detail views

Only put one product to main bundle with Event.VIEW_ITEM key.

  • Additions to cart

There are two different changes from product detail views. Add quantity value for product and change the bundle key with Event.ADD_TO_CART.

  • Removals from cart

Change event key with Event.REMOVE_FROM_CART to measure removals product items.

  • Promotion impressions

For promotion impression, don’t use product items. Put promotions to list bundle with “promotions” key and then log event with Event.VIEW_ITEM.

  • Promotion clicks/selections

Selection promotions’ events have one difference that is key from promotion impression. You can use three different keys: Event.SELECT_CONTENT, Event.VIEW_ITEM_LIST, Event.VIEW_SEARCH_RESULTS.

  • Checkout process

You can log events step by step in checkout processes. Firstly, start your process with Event.BEGIN_CHECKOUT and then use Event.CHECKOUT_PROGRESS key. When you use these keys, set your checkout step like below.

  • Purchases

Last step of checkout progress is purchase step. To measure purchases, add values of your transactions to bundle with new keys. After that you can send purchase event with Event.ECOMMERCE_PURCHASE key.

  • Refunds

To log refunds, add transaction id to bundle and value that is optional. If you specify partial refund, you must add item id. After preparing the bundle, you can send refund event with Event.PURCHASE_REFUND key.

That’s all to measure your events or logs properly. After that follow and analyze these logs to increase your conversion rates.

Important Issues and Limitations

  1. When you add product items to your bundle, you have to add Param.ITEM_ID or Param.ITEM_NAME for your every products.
  2. For promotion items, Param.ITEM_ID or Param.ITEM_NAME are also required.
  3. Default container of Google Tag Manager that is put before publishing, is used just once. When the application connects to internet and downloads new one, default container is never used again.
  4. Just for now, Param.CURRENCY is not used for Firebase Analytics. For next releases, it will be hopefully used.
  5. Param.ITEM_LIST is optional key for naming items’ list.
  6. Maximum 25 unique Params are permitted to send for each Event type.
  7. Custom parameters can be sent.
  8. Parameter’s key can be max 40 chars and alphanumeric values can be used with underscore.
  9. Parameter’s key must be start just alphanumeric character.
  10. Parameter’s value can be long max 100 characters.
  11. firebase_”, “google_” and “ga_” prefixes are not allowed to be used as parameter’s key.

That’s all! I have tried to explain what Enhanced Ecommerce is and how it can be implemented to your projects. Before I said in first story: After five or six years, I started to write something again. If you have any thoughts or comments, I want to hear your words.

--

--