Author Archives: Gary Lewis

Get ready for Javascript “Promises” with Google and Udacity

Sarah Clark, Program Manager, Google Developer Training

Front-end web developers face challenges when using common “asynchronous” requests. These requests, such as fetching a URL or reading a file, often lead to complicated code, especially when performing multiple actions in a row. How can we make this easier for developers?

Javascript Promises are a new tool that simplifies asynchronous code, converting a tangle of callbacks and event handlers into simple, straightforward code such as: fetch(url).then(decodeJSON).then(addToPage)...

Promises are used by many new web standards, including Service Worker, the Fetch API, Quota Management, Font Load Events,Web MIDI, and Streams.


We’ve just opened up a online course on Promises, built in collaboration with Udacity. This brief course, which you can finish in about a day, walks you through building an “Exoplanet Explorer” app that reads and displays live data using Promises. You’ll also learn to use the Fetch API and finally kiss XMLHttpRequest goodbye!

This short course is a prerequisite for most of the Senior Web Developer Nanodegree. Whether you are in the paid Nanodegree program or taking the course for free, won’t you come learn to make your code simpler and more reliable today?

Mobile Bootcamp Part IV: Effectively monetize your app

Originally Posted on DoubleClick Publisher Blog

Users continue to move across platforms and screens. Today, more than half the queries on our platform come from mobile devices, both on mobile web and apps. The balance between monetizing your app and providing a good user experience remains tricky yet essential.

Yesterday, we focused on ways to create a high quality app for your users. Continue reading to gather app monetization recommendations from Mark Wolly, Head of Mobile Publisher Solutions at Google, and find a happy medium between effective monetization and good user experience.

  1. Create ads that respect your UX: Good ad placements ensure reliable revenue without sacrificing user experience. Examine the flow of user engagement within your app to place ads in undisruptive places, such as the transition points in a reading app. You can experiment with the frequency and placements of your ads to ensure you’re delivering the right experience in the right context for the user. Try to avoid sandwiching them between your interactive app content and navigation/menu buttons.

  2. Choose the best ad formats for your app’s content structure: It’s easy for users to get distracted by ads given the limited screen size, especially when they don’t match the look and feel of your app.

    Try using Native ads to create a consistent look and feel across your content and ads. Formatted to fit mobile apps’ content and visual design, Native ads are more likely to be viewed and clicked by users. eBay recently started using our Native Ads on DoubleClick and experienced a 3.6X increase in ad engagement on average, with some campaigns delivering click-through rates up to 5%.

    Mark believes “Native presents an opportunity to reset on building premium quality mobile placements and creatives. Many publishers have already built custom formats for direct sales, but haven’t yet extended their advertiser reach by offering them via programmatic channels.”

  3. Build your programmatic direct strategy: Allowing you high quality creative formats from premium advertisers, programmatic direct introduces your app to new advertiser budgets and makes ad operations easier. As explained by Mark, “Many publishers have built incredible custom mobile formats that command high CPMs from high-quality advertisers. They can massively extend their advertiser reach, while retaining the same cpms and control, by offering these formats to new advertisers via programmatic channels.”

There is a fundamental shift amongst consumers in their use of mobile, making it indisputable that apps play a significant role in a consumer’s mobile experience. In the time that desktop audiences have grown 1%, mobile audiences have grown a staggering 41%1.

Focusing on ways to increase app discoverability, understand user engagement, optimize app quality, and effectively monetize your app, our mobile bootcamp outlines key steps for enhancing your mobile offerings in time for the holiday season of mobile frenzy.

Mobile Bootcamp Part III: Focus on quality

Originally posted on DoubleClick Publisher Blog

At this point, you’ve read our recommendations for growing your app’s audience and keeping users engaged. But there are technical aspects, too, that can make or break your app’s success. Speed, for example, is crucial -- users expect apps to respond in under one second.

Yesterday, we gave recommendations for attracting, engaging, and retaining your users. Continue reading today to learn tips from Dev Gogate, Mobile Solutions Consulting Manager at Google, on providing your users with a high quality app.

  1. The smaller the app size, the better: Users have limited bandwidth and data storage, so a large app runs the risk of losing an install. App stores impose size limits and will only deliver apps under a certain size over cellular connections; Google has a 50MB limit for each APK (but allows 2GB expansion files for supporting media) and Apple limits app size at 100MB. Use the ProGuard tool to optimize your Android code and enable Resource Shrinking to remove unused and unneeded resources from dependency libraries. App Thinning offers a similar solution for decreasing app size on iOS.

  2. Build apps that use device resources optimally: Building apps without taking into account how display interacts with hardware components can drain precious resources, such as battery life. According to Dev, "App performance is critical! A badly designed app can drastically and negatively impact the the user's perception of the app's usability and will surely lead to an uninstall." Dev recommends compiling a list of metrics for your apps to perform against and then running tests. This YouTube Android performance channel and Google+ community offer excellent tips on building high performing apps.

  3. Ensure your app works across devices: Failing to catch a bug or crash that only impacts some devices quickly leads to angry customer feedback and low ratings. Dev recommends using Cloud Test Lab to simultaneously test your app on nearly every brand and model of Android devices and across multiple languages, screen orientations, and Android API versions. Dev’s expert tip: Even if you have not written any instrumentation tests for your app, you can use Robo tests to exercise your app by simulating user actions.

  4. Use A/B testing to get real user feedback: Dogfooding your app provides early insight into how users interact with your app and how it behaves beyond the test lab. Beta testing, on the other hand, gathers feedback from an enthusiastic audience. Since this testing is customer-facing, ensure the process is simple to ensure high user participation. Both of these tests gives you early feedback from users before widely releasing your app.

  5. Launch new app versions in phases and closely monitor: Don’t underestimate the number of users who may adopt a new version of your app and their levels of usage. Dev recommends using staged rollouts, which allow you to beta test different app versions and gradually release app updates with a chosen user group. The Cloud Test Lab provides access to virtual devices that give rapid feedback during development, as well as physical devices that pinpoint issues found on real, physical devices.

Creating a high quality app is essential for building and maintaining a loyal user base. Follow Dev’s recommendations to optimize your app quality and stay posted for our post tomorrow on ways to effectively monetize.

How Twitter used Doze in Android 6.0 Marshmallow to Improve Notification Performance

Posted by Laurence Moroney, Developer Advocate

In October, we published a blog post about how Google Cloud Messaging (GCM) works with Doze in Android 6.0 Marshmallow to bring performance and usability improvements to the user. In this scenario, normal priority messages allow the device to stay in Doze, while high priority messages take the device out of Doze. For a great example of this capability and best practices on Android, we’ve spoken with the engineering team at Twitter.

Twitter has researched extensively which messages should get high priority -- given that this priority can awaken a device in Doze. To meet their particular need, Twitter wanted Direct Messages to be delivered on high priority, where mentions would be at normal priority.

Luke Millar, Android Engineering Manager at Twitter commented "With Android M we have a greater ability to be good citizens when it comes to conserving battery life. This feature lets us specify which notifications will wake up a device in Doze and which ones won't. Normally, we tell GCM to wait to deliver push notifications until the next time the user's phone wakes up. However, users expect to receive some push notifications immediately, like notifications for Direct Messages, so we set those as high priority. It's nice being able to specify when and how those notifications make it to our users."

To test Doze, Twitter’s engineers followed the steps outlined on the Android Developers site. These guide you to use adb commands to simulate doze on either a physical or virtual device. Following this method, Twitter was able to successfully test how their messaging priorities would work in a real-world environment.

One other best practice that Twitter used was in transmitting larger payloads, such as when delivering Twitter Highlights. In this case, they opted to pass metadata in the notification, which was then used to sync the application to get the requested Highlights. In other words, they didn’t transmit the contents of Highlights in a notification, instead triggering a sync mechanism to update the contents of the app.

For more details on using GCM with your app in standby environments, check out the documentation.
You can learn more about Google Cloud Messaging and how to use it for notifications in your Android, iOS and Web Applications at the Google Developers site here.

Mobile Bootcamp Part II: Engage your users

Originally Posted on DoubleClick Publisher Blog

Did you know that 52% of all apps lose at least half of their most valuable users after three months?1 In this environment, how can you ensure your app effectively attracts, engages, and retains users?

Yesterday, we kicked off our mobile bootcamp to help get your app in shape for increased traffic and monetization opportunities during the holiday season. Building on mobile expert Cheney Tsai’s recommendations for growing your app’s audience, Jason Rosenblum, Mobile Solutions Consultant at Google, shares tips for effectively engaging users.

  1. Optimize your on-boarding experience: The first-run of your app is critical in selling its value and utility. Jason suggests using A/B testing to experiment with different features, such as adding an app tutorial or custom discount code.

  2. Measure user engagement and understand how it connects to your business: Knowing whether, when, and how frequently users return to your site allows you to strategically send notifications, identify pain points, and launch features. Cohort analysis indicates patterns in user behavior by aligning all metrics by the different days of user experience, regardless of the specific day a user starts using your app.

    While Google Analytics offers standard measurement options -- average session duration, active users, loyalty, recency, audience overview -- consider the nature of your business to pinpoint significant custom metrics. Jason explains, "You need your analytics to make sense for your business. For example, if you're running a hotel booking site, you want to know the number of hotel searches being run and the number of hotel rooms being booked. Customize your analytics for your business so you can drive the right KPIs."

  3. Remind users of your app’s value: 34% of app abandonment is fueled by a loss of interest, so create rich, contextual notifications like latest news, weather, or reminders to re-engage and increase your daily/monthly users. Google Cloud Messaging, for example, allows you to implement and manage notifications across Android and iOS. Jason advises using rich notifications to add quick actions, such as the ability to Archive an email via gMail notifications, and allowing users to control whether and how often they receive notifications.

The total time spent in apps per smartphone user is increasing, yet the total number of apps used has not changed. Users, therefore, are consolidating their time in certain favored apps. Incorporate Jason’s recommendations to keep your users engaged and come back tomorrow to hear from Dev Gogate, Mobile Solutions Consulting Manager at Google, to maximize your app quality.

Google Cloud Messaging – We’ve Come a Long Way

Posted by Laurence Moroney Developer Advocate

Google Cloud Messaging (GCM) is a technology that provides simple and reliable messaging to devices. In the last six months, the number of messages that GCM handles has more than doubled -- to 150 billion messages per day, and the number of applications has grown 25% to 750,000. With this growth in mind, we’re continuing to improve the service with some helpful updates for developers.

Google Cloud Messaging supports topic messaging - an easy way to segment your users’ devices into groups and send a message to the entire segment at once. We’re now happy to announce that we’re allowing unlimited free topics for your app. This means app developers can place an unlimited number of devices within each topic and create an unlimited number of topics.

Moovit uses topics to efficiently scale

Moovit, a community of 30 million+ users, helps improve transit routes in cities worldwide. Using GCM, Moovit has been able to create over 60,000 topics to help users in individual cities navigate the headache of daily transit.

"We started using GCM to power our push infrastructure in a more seamless, efficient way. Not only does GCM help us to send real-time updates to a high volume of tens of millions of users, keeping them informed of any transit information they need for a stress-free commute, but we don't have to spend extra time or energy developing an infrastructure for delivery on the backend. GCM Topics allows us to message users in hundreds of cities around the world with multi-platform support for both iOS and Android."

For example: Users of London’s Underground Service were impacted by recent strikes that disrupted the regular service. While Moovit has a global audience, only those impacted were notified, as Moovit used GCM topic messaging to send the message to only those that needed it.

National Public Radio (NPR) uses Topics for news personalization

NPR is a mission-driven multimedia news organization and radio program producer in the United States. To reach their users efficiently, NPR sends and schedules personalized notifications to their listeners

via their NPR One App. For example, if you listened to the Aziz Ansari interview on the show All Things Considered, and wanted to hear more, you could subscribe to the topic ‘Aziz Ansari’ and receive a notification of his appearance on the Hidden Brain podcast. Similarly, you could subscribe to other topics such as Election 2016, Women in Combat or Pop Culture Happy Hour.

Tejas Mistrly, Mobile Product Manager for NPR, described their use of topics: “With GCM topic messaging, NPR is able to send and schedule personalized notifications to our listeners on NPR One. Whether to catch them up on the latest news or to tell them a story from a recommended podcast across public radio, GCM topic messaging gives us the tool set to send the most effective notifications that ties into our personalized radio app.”

New APIs for GCM topic management

Complementing unlimited free topics and the existing client-side API, we’re launching a new suite of server APIs that allow you to manage message subscriptions. The new APIs allow you to subscribe/unsubscribe devices individually or in batches, as well as allow retrieval of info on current subscriptions per device. We think the server-side API is a great tool to help you reduce roll-out friction, and allow for easy management and migration of subscriptions as your app grows.

To learn more about Google Cloud Messaging, visit the Google Developers Site, where you can learn more about how to build for this technology, and download sample implementations. There’s also a full reference implementation available on GitHub and the GCM Diagnostics tool for when you need help to troubleshoot.

Advanced Development Process with Apps Script

Originally posted on Google Apps Developers blog

Posted by Matt Hessinger, Project Specialist, Google Apps Script

Welcome to our 100th blog post on Apps Script! It’s amazing how far we’ve come from our first post back in 2010. We started out highlighting some of the simple ways that you could develop with the Apps platform. Today, we’re sharing tips and best practices for developing more complex Apps Script solutions by pointing out some community contributions.

Apps Script and modern development

The Apps Script editor does not allow you to use your own source code management tool, making it a challenge to collaborate with other developers. Managing development, test, and production versions of a project becomes very tedious. What if you could have the best of both worlds — the powerful integration with Google’s platform that Apps Script offers, along with the development tooling and best practices that you use every day? Now, you can.

npm install -g node-google-apps-script

This project, “node-google-apps-script”, is a Node.js based command-line interface (CLI) that uses Google Drive API to update Apps Script project from the command line. You can view the node package on the NPM site, and also view the GitHub repo. Both links have usage instructions. This tool was created by Dan Thareja, with additional features added by Matt Condon.

Before using the tool, take a look at the Apps Script Importing and Exporting Projects page. There are a few things that you should be aware of as you plan out your development process. There are also a few best practices that you can employ to take full advantage of developing in this approach.

There is a sample project that demonstrates some of the practices described in this post: click here to view that code on GitHub. To get all of the Apps Script samples, including this import/export development example:

git clone https://github.com/google/google-apps-script-samples.git
The sample is in the “import_export_development” subdirectory.

Your standalone Apps Script projects live in Google Drive. If you use a command-line interface (CLI) tool like the one linked above, you can work in your favorite editor, and commit and sync code to your chosen repository. You can add tasks in your task runner to push code up to one or more Apps Script projects, conditionally including or excluding code for different environments, checking coding style, linting, minifying, etc. You can more easily create and push UI-related files to a file host outside of Apps Script, which could be useful if those same files are used in other apps you are building.


Typical development tools, integrated with Apps Script via the Drive API

Apps Script Project Lifecycle Best-practices

In addition to the information on the Importing and Exporting Projects page, here are a few things to consider:

  • Your local file set is the master. If you add, delete or rename files locally, the next upload with either of the linked tools will automatically make the Apps Script project reflect your local file set.
  • You can name local files whatever you want. You just need to then append “.html” to any client-side “.js” or “.css” in a file staging task before uploading to your project. The tool referenced above treats any “.js” files that you stage for upload as Apps Script server script files (“.gs” in the editor). It treats any “.html” that you stage as “client” code that you’ll access via the HtmlService. This means that you can develop server scripts as JavaScript, with the “.js” extension, so that your local tools recognize JavaScript syntax. While developing, client-side code (i.e., code that you need to interact with via the HtmlService) can be “.html”, “.js”, or “.css”, allowing your editor to provide the right syntax highlighting and validation experience.

Over and above the editing experience, the biggest improvements you get by working outside the script editor is that you are no longer locked into working in just one Apps Script project. You can much more easily collaborate as a team, with individual developers having their own working Apps Script projects, while also having more controlled test, user acceptance and production versions, each with more process and security. Beyond just the consistency with other normal project practices, there are a few Apps Script specific ways you can leverage this multi-environment approach.


If you are going to use this approach, here are three best practices to consider:

  • Use specific configuration values for “local” development.
  • Build test methods that can run standalone.
  • Include dependencies for development and testing.

Best practice: Use specific configuration values for “local” development.

The provided sample shows a simple example of how a base configuration class could allow a developer to inject their local values for their own debugging and testing. In this case, the developer also added the annotation @NotOnlyCurrentDoc, which tells Apps Script that they need the full scope for Drive API access. In this project, the “production” deployment has the annotation @OnlyCurrentDoc, which leads to the OAuth scope that is limited to the document associated with script running as Sheets, Docs, or Forms add-on. If you add a standard file pattern to the source project’s “ignore” file, these developer-specific files will never get into the actual codebase.

Benefits for your project — Production can have more limited OAuth scopes, while a developer can use broader access during development. Developers can also have their own personal configuration settings to support their individual development efforts.

Best practice: Build test methods that can run standalone.

While there is no current way to trigger tests in an automated way, you still may want to author unit tests that validate specific functions within your projects. You’ll also likely have specific configuration values for testing. Once again, none of these files should make it into a production deployment. You can even use the Apps Script Execution API to drive those tests from a test runner!

Benefits for your project — You can author test functions, and keep them separate from the production Apps Script file. This slims down your production Apps Script project, and keeps the correct OAuth scopes that are needed for production users.

Best practice: Include dependencies for development and testing.

If you are developing an add-on for Sheets or Docs, and you expect to have an “active” item on the SpreadsheetApp. However when you are developing or testing, you may be running your Apps Script without an “active” context. If you need to develop in this mode, you can wrap the call to get the current active item in a method that also can determine what mode you are running in. This would allow your development or test instance to inject the ID of an “active” document to use for testing, while delegating to the getActive* result when running in a real context.

Benefits for your project — You can integrate better unit testing methodologies into your projects, even if the end deployment state dependents on resources that aren’t typically available when debugging.

Wrapping up

You now have the option to use your own development and source management tools. While you still do need to use the Apps Script editor in your application’s lifecycle — to publish as a web app or add-on, configure advanced services, etc. — taking this step will help you get the most out of the power of the Apps Script platform. Remember to check out Apps Script on the Google Developers site to get more information and samples for your Apps Script development.

If you happen to use python tools on the command line to facilitate your team’s build process, you can check out Joe Stump's python-gas-cli. You can view the package info here or the GitHub repo where you’ll also find usage instructions.

Here are some additional reference links related to this post:

Mobile Bootcamp Part I: Get your app into shape for the holiday season

Originally posted on DoubleClick Publisher Blog

During the 37 hours per month typically spent in apps, people look to their mobile devices for information and entertainment.

This comes as no surprise, however, to our DoubleClick customers. You already see most of your audience is mobile: more than half the queries on our platform today come from mobile devices, across mobile web and apps. This holiday season will bring increased traffic and even greater potential to grow revenue, peaking in January. Mobile app installs are expected to increase by 150% on Christmas Day compared to an average day in December.

To help you take advantage of the surge in user activity on mobile, and particularly in apps, we’ve gathered our most actionable research and best practices. Make the most of the holiday app frenzy with this four-day mobile bootcamp on reaching, engaging, and monetizing your app audiences.

Grow your app’s audience

Of the five hours per day that US consumers spend on smartphones, 54% of digital media time is spent in apps. How can you ensure your app is one of those? Cheney Tsai, our Mobile Solutions Consultant at Google, recommends five steps to help you connect with your audience everywhere.

  1. Get people talking about your app: 52% of users learn about an app from friends, family, or colleagues, proving yet again word-of-mouth is a reliable promotion method. Cheney suggests using App Invites, a beta feature for iOS and Android, which allows users to invite Google contacts to your app via email and SMS. As explained by Cheney, "First impressions matter! App Invites allow you to reach new users with a warm welcome, which could be game-changing for the long term value of your user. You can even reward the sender/receiver with a custom deal just for them."

  2. Make it easy for your existing users to find you, everywhere: By expanding your house ad campaigns to cross-promote on existing properties, you can target desktop users in addition to those on Android and iOS. Use App Indexing to redirect your SEO based traffic to your app; users who have the app are redirected into it while those without the app are prompted to install. Also, make sure your Google Play Store badge is prominently displayed on your website. Users are 47% more likely to trust and download apps upon seeing the Google Play badge!

  3. Optimize your creatives to pique users’ interests in stores: Your app’s presentation in app stores directly impacts downloads. Since the icon is the first impression, make it polished and descriptive with a featured image demonstrative of your app’s uniqueness. Experiment with the Play Store’s A/B testing features for different versions of graphic assets, titles, and descriptions. Cheney recommends playing up keywords with which users are most likely to find your app!

  4. Identify high performing channels and optimize with better analytics: Pinpoint your most successful app install campaigns and creatives to create an effective promotion strategy. For both iOS and Android, you can use Google Analytics to understand your user drop off points. Dive even deeper with app install tracking and custom campaigns to identify your top app referrers!

  5. Listen to your users and address their concerns: User comments may offer constructive feedback, so it’s integral to have a plan in place to respond and make changes. In Google Play Developer Console, you can reply to reviews to help users overcome a problem or communicate relevant information. According to developers like James Jerlecki at Text Plus, “The Reply to Reviews feature has essentially given me that direct line [to users] that I didn’t have before.”Just remember your reply is publicly visible, so ensure you have the right person in your organization replying.

With over 3.1 million apps across the Google Play and Apple stores, your app needs to be present whenever users are looking to discover new apps and stand out from the crowd when they find your app. Check out this blog tomorrow for recommendations from Jason Rosenblum, Mobile Solutions Consultant at Google, for engaging your users.

Our new global program for Developer Agencies

Posted by Uttam Kumar Tripathi, Global Lead, Developer Agency Program

The Google Developers team supports a number of global programs geared up to help make developers successful. Google Developer Groups aims to build and foster local developer communities globally, while Women Techmakers provides visibility, community and support for women in tech. Elsewhere, Launchpad offers resources for startups to help them launch and scale their apps. Through all these programs, our goal has been to positively impact the experience of developers and startups globally as they build products and apps on Google and other open source technologies.

In today’s app economy, a large number of mobile and web apps are created by developer agencies globally. These agencies cater to the needs of large enterprises and small startups by helping them build applications that range from proof of concepts to fully featured apps. Because developer agencies play a central role in the success of the ecosystem in many markets, it was important to build a comprehensive program that provided more dedicated support.

That’s why we’re excited to announce our new Google Developers Agency Program. Through this program we will work with developer agencies around the world, providing them with dedicated access to training and events, customized online resources, best practices, and developer support. Ultimately, we want to help agencies build the highest quality apps and products using Google technologies, ensuring they’re at the top of their game and delivering the best app experiences for their clients’ needs.

Soon, we’ll also provide a directory of the agencies we’re working with on our website. If you’re a client looking for an agency to help with your app requirements, you’ll be able to easily find trained agencies who have access to resources from Google for the job.



The program will first roll out in India, UK, South East Asia and the US. We plan to expand to more countries throughout 2016. To learn more about this initiative and show interest, visit developers.google.com/agency.

Enhancements to the Classroom Share Button

Originally posted on Google Apps Developer Blog

Posted by Andrew Garrett, Software Engineer, Classroom API and Michael Stillwell, Developer Advocate, Google Apps

By popular developer request, the Classroom Share Button now supports JavaScript callbacks and a question post type (in addition to announcements and assignments).

The following callbacks are supported:

  • onsharestart is called immediately after the user clicks the share button
  • onsharecomplete is called after the user successfully shares the URL to their class

The callbacks are supported by both the share tag and the JavaScript API, and they work on all supported browsers except Internet Explorer.

What can you use this for? There's a bunch of different things you can do, but to get you started, here are some suggestions:

  • Analytics and reporting How frequently is the share button used? What's the most frequently shared URL across the site?
  • Shared URL history Store the list of URLs a user has shared, to provide a customized and more engaging site.
  • Contextual help The first time a user shares a link back to your site, explain what happened and what they should expect to see next.
  • A/B testing Are many users starting a share action, but failing to finish?

Finally, if you want to fully control the appearance and behavior of the share button (and don't need the callbacks), you can customize the Classroom icon (as long as it still meets our branding guidelines) and initiate the share via a URL of the form:

https://classroom.google.com/share?url=https://foo.com/

As ever, please continue asking questions (or answering them!) on StackOverflow (use the google-classroom tag) and report bugs and feature requests via the Classroom API bug tracker.