Members-only tutorial

Watch the video and get the practice sheet with membership.

See membership options

Add NPS to Your Google Site

About this Tutorial

Create buttons on your Google Site to get an NPS, or Net Promoter Score directly to a Google Sheet.

Featured Formulas

Video Transcript

<div>00:00 Pretty simple, in this video we're going to add an NPS score uh taker or rater to your Google site.

Uh it's going to use a little bit of Apps Script Learn how to use Apps Script to enhance your Google Sheets and Sites. Opens in new tab but I will show you, I will write it here live so you will see it is not that much and if you're a BetterSheets member and watching this on BetterSheets.co<br>00:17 you can get this exact sheet down below if uh if you're on BetterSheets.co if you're anywhere else, alright gotta go to BetterSheets to get it or uh Udemy as well, I might pop this into Master Spreadsheet Understand the basics of Google Sheets and how to manipulate data. Opens in new tab Automation So, what we're going to do is we need a Google site, right?<br>00:33 We have a Google sheet, it's a brand new sheet but let's get a brand new site, site.new Slash 3 cause I have a bunch of accounts but this is a brand new Google sheet page, uh Google site, NPS score You can write whatever you want here, we're just going to add some buttons, we're going to go over to the<br>00:48 right side, we're going to add a button We're going to call this 1, we will get a link, so what an NPS score does is it will allow someone who is buying your product using your product.<br>01:00 to rate you 1 to 10, how likely are you to refer this product to someone else, to a friend.

So, you can insert these 10 buttons anywhere on your site into a section or on another page if you're like, hey go over to my NPS and rate me, let me know how I'm doing, right?<br>01:22 And the question is, how likely are you to refer this product to your friends and it is going to be a number Explore how to work with numbers in Google Sheets and Apps Script. Opens in new tab .<br>01:30 between 1 and 10 and we will take in that number Explore how to work with numbers in Google Sheets and Apps Script. Opens in new tab with this button, so this is going to be a button, we need a link, how do we get a link, well let's call this a score and then we also want a timestamp Discover how to create and format timestamps in your scripts. Opens in new tab because the data Get insights on managing and utilizing data effectively in Sheets. Opens in new tab that we're going to get in is going to say a number Explore how to work with numbers in Google Sheets and Apps Script. Opens in new tab and we will be adding up that number Explore how to work with numbers in Google Sheets and Apps Script. Opens in new tab <br>01:50 to get a total aggregate score or averaging that number Explore how to work with numbers in Google Sheets and Apps Script. Opens in new tab , but over time what we want to do is increase that number Explore how to work with numbers in Google Sheets and Apps Script. Opens in new tab , right, and say we want the end result on total to increase over time, meaning we don't want to take the aggregate of everything, we want to know what came in first, so that's why we do a<br>02:09 timestamp, so let's go to Apps Script and start coding right away, it's not going to be much, don't worry, and again, you can grab this sheet down below if you're on bettersheets.co, so the function we need right now is going to be a doGet, we need an event or some parameters here, we will just say the<br>02:29 letter E here, but you can also say P.

Event, if you want, uhm, but we're just going to use the letter E, one letter.<br>02:36 What do we want? We want the score. So when we get the URL, we are going to add to it a parameter Learn about parameters in Apps Script and how to use them. Opens in new tab that says score, and that will be E variable score equals E. parameter Learn about parameters in Apps Script and how to use them. Opens in new tab .score, and we can say the name of this, we can set it whatever we want, you'll see later that we will use the word score to get this,<br>02:59 uhm, and I'll show you how to do that. on the URL.

But what are we going to do with the score?<br>03:03 We're going to go to the spreadsheet Understand the basics of Google Sheets and how to manipulate data. Opens in new tab , uh, that we have here, go to sheet one, actually we're going to call this scores, all uppercase, we're going to get the active spreadsheet Find out how to reference the active spreadsheet in your scripts. Opens in new tab , this entire file that we're in now, we're going to get sheet by name, get sheet by name, we're going to go to scores, we are<br>03:22 going to find, uhm, get range Understand how to define and manipulate ranges in Google Sheets. Opens in new tab , we're going to find the last row, last row, we're going to put into to column one.<br>03:32 only one size, one by one, we are going to set the value, and this value will be the score.

But what is this last row?<br>03:42 Let's go find it. We will need all of these scores again, like the sheet scores, so actually I'm going to cut it and call it variable scores sheet equals, and it'll just be this score, So we'll call this scoresSheet. getRange Learn how to retrieve specific ranges of data in your spreadsheet. Opens in new tab setValue Discover how to set values in your Google Sheets using Apps Script. Opens in new tab .<br>03:59 But we need that last row. So we'll say variable lastRow equals scoresSheet. getLastRow Find out how to get the last row of data in a Google Sheet. Opens in new tab . Simple as that. We just get the last row, but we don't want to actually put it on the last row.<br>04:15 The issue is we're going to get the last row.

The last row means the last row that has data Get insights on managing and utilizing data effectively in Sheets. Opens in new tab in it.<br>04:19 We don't want to rewrite over and over again. So we need to add plus one.

Get the last row, add one.<br>04:25 Make sure we're adding a row each time, so actually I will go here, I'm gonna delete all of these rows we're going to then do scoresSheet. appendRow Learn how to append new rows to your Google Sheets dynamically. Opens in new tab and we're just gonna append a row at the end and then we're gonna put right under the last row, set the value score.<br>04:44 We also want to do one more thing, which is take all of this and we're gonna set one more value in the second column and that value will be the timestamp Discover how to create and format timestamps in your scripts. Opens in new tab .<br>04:54 Well what is the timestamp Discover how to create and format timestamps in your scripts. Opens in new tab ? Let's add it up here and call it variable timestamp Discover how to create and format timestamps in your scripts. Opens in new tab equals.

I'm going to format Explore formatting options for better presentation of your data. Opens in new tab it, but really you just need new date with a new then capital D date with parenthesis.<br>05:10 You really only need that, but it's gonna give you a timestamp Discover how to create and format timestamps in your scripts. Opens in new tab and that timestamp Discover how to create and format timestamps in your scripts. Opens in new tab 's gonna have all like milliseconds, everything. So we're gonna do utilities, utilities.formatDate and wrap Understand how to wrap text in cells for better readability. Opens in new tab this in parenthesis and as you see here we can choose the time zone Learn about setting time zones in your Apps Script projects. Opens in new tab .<br>05:29 Let's just GMT um, minus, actually just GMT, doesn't really matter. You can set any time zone Learn about setting time zones in your Apps Script projects. Opens in new tab you want. Minus six plus eight, whatever you want.<br>05:39 Format Explore formatting options for better presentation of your data. Opens in new tab , this is gonna be the interesting part.

We can format Explore formatting options for better presentation of your data. Opens in new tab this any way we want. We're gonna do the year, month, hyphen, the day, and also a space, an hour, colon, and then two Ms for minutes.<br>05:57 Okay, I'm going to do all that. Now, here's the important part we need We are going to name it and then deploy it.<br>06:04 Name it nbsgetter, click deploy, new deployment. We need a URL. Basically, we're allowing this spreadsheet Understand the basics of Google Sheets and how to manipulate data. Opens in new tab to be open to the public but only through this URL and only gonna do exactly what we have selected it to do.<br>06:21 We're going to select Discover how to use the SELECT clause in your queries. Opens in new tab the type web app.

We will execute as Understand the 'execute as' feature in web apps for permissions. Opens in new tab ourselves, as me, and it will be available to anyone.<br>06:27 So anyone that has this URL can enter some script. We will, I'll show you how that works. But they will only be able to do that.<br>06:35 That's a really cool thing about this do get and allowing this web app URL Learn how to create and use web app URLs in your projects. Opens in new tab to be out there. People can't enter your sheet.<br>06:42 They can't edit or delete your sheet at all but they can do whatever you've prescribed for them to do. We will authorize access.<br>06:51 The access they will have is that they can enter a new line.

And we will allow, which is pretty simple stuff, just to be able to enter lines.<br>07:01 Set a date, done. We will copy this web app URL Learn how to create and use web app URLs in your projects. Opens in new tab once we get it. And we will now put a link here in our Google site.<br>07:11 Again, the name of the button is just 1 because we just want the score of 1. But we have a link that we will use for the entire, all 10 numbers.<br>07:18 But at the end we will do question mark score equals 1. So that's all we need to get the data Get insights on managing and utilizing data effectively in Sheets. Opens in new tab of the score 1 into this button.<br>07:29 So we will insert that there, we will, duplicate Find out how to duplicate elements in Google Sheets efficiently. Opens in new tab it, we will call it 2.

At the end we will write 2, update.<br>07:38 Let's put this next to, there. And let's test this, right? Let's see how this is going, um, and is it going to work, right?<br>07:47 Let's publish Explore the steps to publish your Google Sites and Sheets. Opens in new tab our sheet to NPS. Uh, let's see who can, who can view it. We want the draft restricted Understand the implications of restricted access in Google Sites. Opens in new tab , but we want the published site to be anyone public, right?<br>08:01 We want to do it. Direct people here, uh, to score us. Or maybe we're adding this already to our sheet, uh, or to our site.<br>08:08 Alright, let's click publish Explore the steps to publish your Google Sites and Sheets. Opens in new tab . Okay, it is published.

We can view it, but in order to execute these things we need to do it on a incognito tab, cause we can't, uh, to do it.<br>08:28 Let's delete all of that and just get the bare URL. There we go. We have an incognito tab. We have one.<br>08:36 It's gonna maybe give us an error Learn how to troubleshoot common errors in Google Sheets. Opens in new tab . Yeah, we need an error Learn how to troubleshoot common errors in Google Sheets. Opens in new tab . Oh, we need to fix this. So back in our code, I think we used append row.<br>08:45 Um, yeah, we don't need to actually do this. We can do insert row Discover how to insert rows in your Google Sheets programmatically. Opens in new tab after last row. Let's do that instead of the append row.<br>09:05 And we need to deploy this.

We can keep the same URL if we click on manage deployments. We go to our untitled one, which is the only one we have.<br>09:14 Click edit and we select Discover how to use the SELECT clause in your queries. Opens in new tab the new version. We can add a new description. Uh, insert row Discover how to insert rows in your Google Sheets programmatically. Opens in new tab . Click deploy. We will keep the same URL.<br>09:26 Let's go. Actually, we need to do something else too here. So, one thing I just totally forgot to do is, Return contentService.<br>09:35 And we're just going to return a code that says 200. Hey, it worked. ContentService.createTextOutput 200. This will show up to the user.<br>09:43 So, let's actually not just say 200.

Let's say uhm you, thank you. You scored, you entered a score of, and then add a plus and the score.<br>10:02 Whatever they entered. So, let's see if that's going to work. Manage deployments. Again, we will make sure it is deployed.<br>10:09 We will edit up here. Version. Select Discover how to use the SELECT clause in your queries. Opens in new tab new version. And do added return. Deploy. Again, should be the same URL. So, we don't have to actually change our site.<br>10:22 We can go to our site in an incognito window. Let's click on the number Explore how to work with numbers in Google Sheets and Apps Script. Opens in new tab 1. Let's see what happens. You entered a score of 1.<br>10:34 Did we? Let's go check our sheet. And there we go.

We have a score of 1 and we have the timestamp Discover how to create and format timestamps in your scripts. Opens in new tab .<br>10:42 We have the exact timestamp Discover how to create and format timestamps in your scripts. Opens in new tab that it was selected. So, what's really cool now is we can obviously duplicate Find out how to duplicate elements in Google Sheets efficiently. Opens in new tab this as many times we want.<br>10:53 Edit this to 10. Edit the score to 10. Update. Now let's duplicate Find out how to duplicate elements in Google Sheets efficiently. Opens in new tab it again. Right, and you can see where Learn how to use the WHERE clause in your data queries. Opens in new tab we're going with this.<br>11:04 We're going to have 10 buttons here. How likely are you to uh refer this to a friend? How likely are you to refer our product, let's just call it better sheets, for better sheets to a friend?<br>11:27 How likely are you? Let's vote.

All right, we can take a break. Decrease this a bit. Uh, we still need to add a few more here.<br>11:39 Just trying to format Explore formatting options for better presentation of your data. Opens in new tab it so it all fits here on one line. Let's make sure we have them all. Again, this is a little tedious, but it's allowing us to create these buttons really fast without having to create more and more code.<br>11:53 We just edit the score here and update, duplicate Find out how to duplicate elements in Google Sheets efficiently. Opens in new tab , I'm going and edit this 5. Edit the score here 5. We can also change it to the word 5 if we want.<br>12:09 I don't know if we really want to do that. But edit this, edit the score 6.

We are almost done with all of these, right?<br>12:18 We need to make this smaller. Duplicate Find out how to duplicate elements in Google Sheets efficiently. Opens in new tab again. Oh my god, we're so close. 7 and update this to 7 update.<br>12:33 One more and let's keep that 9 and 10. I don't know why we want to do that but that'd be funny.<br>12:42 There we go. So again, publish Explore the steps to publish your Google Sites and Sheets. Opens in new tab and this will be new, uh available. Let's view publish Explore the steps to publish your Google Sites and Sheets. Opens in new tab site. We can delete all of this stuff and again we just need to use the incognito tab just because of our script because we're logged in.<br>13:01 Let's click 9. Double check that it's all working. You entered a score of 9. Perfect.

Let's do 10. You saw enter score of 10.<br>13:13 Let's see is it on the Google sheet? It is on the Google sheet. Now what's really cool is we can insert a row above and be like here's our average score.<br>13:21 Average A3 colon A. We have a score of 6 now. Let's do some more. Let me click 9 a couple more times.<br>13:33 And we're just looking at this that it's entered a score of 9. Entered a score of 10. Great. Let's go back to our sheet.<br>13:43 Score of 7. Average score of 7.8 right? So it's just averaging this and now we have a live score. A NPS score.<br>13:50 Net promoter score.

Ah and it's getting it from Google sites. So we can put that Google site block into anywhere we want.<br>13:57 We can have a link to it. We can add it to our Google Sites. Really cool to have this NPS score.<br>14:02 And pretty darn easy right? We had a little bit of code. Again if you're a BetterSheets member you can grab this code down below.<br>14:08 It'll be down below if you're watching this anywhere else. Go become a BetterSheets member today. Bye.</div>