Differentiating Google Addon Sidebar features based on a license
Published: January 29, 2023
I always get requests as to how people can add a license to their Google Addon. There are a few different steps and here I will show how you can share different information in the Sidebar based on a license status.
Building on a previous post, I will be using Templated HTML in a legacy Google Editor Addon. Feel free to check out the previous post with the simple Templated HTML: https://automagicalapps.com/blog/templated-html-in-addon-sidebar
We are going to add 2 bits to that initial code:
- License Structure
- Delivering different features based on License Structure
License Structure:
There are a variety of ways you can store your licensing backend information. The simplest is to use the built-in Properties Service: https://developers.google.com/apps-script/reference/properties/properties-service For user licensing we will be using the UserProperties component.
We will create a separate function called licenseDetermination where we call the Properties Service and the "license" property and return a value.
Now we need a way to test out our license so we create a function to set the license to this user and their userProperty
Now we can implement these functions into our showSidebar code
Delivering different features based on License Structure
Recall the showSidebar code from the previous post, we will add a couple of lines of code to call that function and based on the return value, create a statement to pass onto the Templated HTML in the Sidebar.
The new bits of code
Running the Addon now with the default (a user with no license) gives the default statement.
Run the setLicense function to give the 'individual' value to the 'license' property.
Now running the Addon will show us the change in the Sidebar.
Now the Sidebar will show different content based on the license value. Using this structure, we can extend to allow a free number of uses before showing a paywall. I will show that extension in the next part (hopefully ;) There are other ways you could achieve the same goal. You could show a different HTML file based on the license value.
As always, hit me up by email or on LinkedIn or Twitter with any questions!