Analytics Buddy Gmail add-on

When Google opened up Gmail add-ons to all developers I jumped at the opportunity to build an add-on. I wanted to share some things I learned along the way.

1) My initial interest was piqued because the Gmail add-on framework provides you with context. Here’s why I think it’s powerful.

With Gmail, my task is to read and deal with emails (with me so far?). When my mind is thus in “email-mode” it would be nice and helpful if I can get additional information about the email I’m reading (to perhaps compose a better reply). The point is that the primary task is email: any additional information, however helpful it might be, has greatly diminished value if it’s only accessible in a different context/screen/app. The key is that I have access to relevant information in the context of the current email. For example, it would be nice to know if the support email I got is from a new or repeat customer. Or when a new order comes in, what marketing campaign lead to that order. But if that entails having to open another tab, log in to a CRM system, do a search, etc… then that’s a lot of extra steps and context switching. Chances are that I’d forget to go look for that info in the first place. With the Gmail add-on framework, I can get relevant information right there next to the email on my screen. And Gmail itself could turn into the next huge app platform.

2) Rich, cards-based UI. As a non-designer I very much appreciate being able to build a UI with the provided Card Service. It’s basically a Javascript API. You instantiate a new Card, which in turn gives you various methods to add components to your UI card, such as text fields, menus and buttons. Actions allow you to add interactivity to button clicks and navigation items. What you can build thus depends on the methods exposed by the Card Service, but on the plus side you don’t have to dig into CSS or HTML to make sure your app displays properly. This may limit your design freedom, but in my case at least, such constraints are good and it means that the design of the add-on stays consistent with the rest of Gmail. Which brings me to my next point.

3) Gmail add-ons work on different platforms out of the box. Your add-on will work in the web version of Gmail, the Gmail Android app and the iOS Gmail app (at the time of this writing, the iOS version wasn’t launched yet). No change required in your code to target these different platforms. Talk about potential distribution, all provided for you!

4) Serverless. You use Google Apps Script to build your add-on. No servers to provision, so I can just focus on the code and app logic. In order to provide useful contextual information you’ll likely retrieve data from an API. Google API are obviously well-integrated, but you are subject to quotas. Am not sure how many app users would start triggering quota limits.

5) Gmail add-ons are built with Apps Scripts, which is “Javascript in the cloud”. Pro tip: you can add third party JS libraries such as lodash.js to your Apps Scripts projects. Very cool.

6) Security and authorization. In order to get your add-on published you’ll have to submit an application and get your API scopes approved and white-listed. In my experience this process was quick and fair, but also rigorous. If you accidentally (as happended in my case) request a scope that your app doesn’t actually use, you’ll get called on that. This process forces you to really think about what minimum scopes you need in order to provide your app’s functionality.

All in all I found building a Gmail add-on approachable and fun, yet powerful enough to let me implement the idea I had and learn some new stuff along the way.

So what did I build?

I want to provide online retailers with a way to get more information from Google Analytics when they view an order confirmation email in Gmail, such as the device type and marketing campaign. The result is Analytics Buddy. If you run an online store, such as Shopify or Yahoo Store, please check it out.

Analytics Buddy

I do fear that it may be too hard for some people to set up because you have to tell the add-on how to match transaction ids using Regex.

Analytics Buddy Regex

It’s also assumed that Google Analytics is properly configured with e-commerce tracking enabled. And obviously you’ll need to generate orders in the first place… I hope that those people who can clear these hurdles will be delighted!