Members-only tutorial
Watch the video and get the practice sheet with membership.
About this Tutorial
Sheet Resources
Video Transcript
<div>0:01 Hello, so we're creating an NPS score for embedding into website, so this is what I created. It's better sheets NPS score, you can actually go to bettersheets.co slash NPS and see this score.<br>0:12 Uh, and you can also do the survey if you wish. Uh, and that is powered by a Google form Learn about Google Forms and how they can be integrated into your projects. Opens in new tab and this number Discover how to work with numbers in Google Sheets and beyond. Opens in new tab is powered by a Google sheet.<br>0:21 And this is all based on this line of code.
So we use function Understand functions in Google Sheets and how to use them effectively. Opens in new tab to get in our app script Explore Google Apps Script and its capabilities for automation. Opens in new tab to create this, uh, code which just grabs literally one cells Get to know how to manipulate cells in Google Sheets. Opens in new tab .<br>0:34 I want to walk through with the entire process of this, but I do want to tell you that you can get this spreadsheet Learn the basics of Google Sheets and its functionalities. Opens in new tab itself.<br>0:40 Uh, I'll create a copy of it that you can get. And I included tailwind and ruby code here. The exact tailwind and ruby code.<br>0:48 That I use. So if you want to make any changes to this and use your own, if you use tailwind and ruby great, you can keep everything except just change out the URLs which I'll go through in a moment.<br>0:57 Umm.
You'll need a Google format Find out how to format your data in Google Sheets for better presentation. Opens in new tab and Google sheet for that. But if you are not Using ruby and not using tailwind, you will have to convert this.<br>1:07 But I'll try to walk through this a little bit. Umm. To tell you how this is working. Umm. Because this is a pretty cool.<br>1:13 And for those who are non technical. Umm. Maybe just a little bit of explanation will allow you to copy paste the.<br>1:21 Code and use it on your site. If you wish. If you have any issues or problems of course you can always email me anytime.<br>1:29 So this is a net promoter score. I will try as a user take the survey.
I'll click number Discover how to work with numbers in Google Sheets and beyond. Opens in new tab 10 here.<br>1:34 How likely are you to. Thank for watching! Recommend. Better sheets to a friend or golly. Let's if I want to add anything else I can.<br>1:41 But let me just submit a number Discover how to work with numbers in Google Sheets and beyond. Opens in new tab . Number Discover how to work with numbers in Google Sheets and beyond. Opens in new tab 10. Great! Thank you for response and let's go back to the sheet and should be something different.<br>1:49 Now it is not 8.4 something is 8.5. So this changed automatically. How does this work? So as I mentioned before I have Ruby and Telling embedded here.<br>2:01 But the actual embedding is pretty simple. Let's go to our sheet and look at it.
We have our responses as a form.<br>2:09 Normal form linked to a sheet. And the sheet here is just the average of everything in B2. This is the score.<br>2:18 I did get the count just in case I wanted to show that as well. So again we'll go to extensions, Apps Script Explore Google Apps Script and its capabilities for automation. Opens in new tab .<br>2:24 And over here in our code it is a function Understand functions in Google Sheets and how to use them effectively. Opens in new tab do get. We're getting the variable data Understand data handling in Google Sheets and how to manage it. Opens in new tab which is spreadsheet Learn the basics of Google Sheets and its functionalities. Opens in new tab app.getactive spreadsheet Learn the basics of Google Sheets and its functionalities. Opens in new tab which is the entire file.<br>2:33 We're getting the name of the sheet by the name score. We're getting a1.
Just the value that it's in a1.<br>2:41 Then we're returning using content service dot create text output and we're converting that data Understand data handling in Google Sheets and how to manage it. Opens in new tab no matter what it is to a string Learn about string manipulation in Google Sheets and Apps Script. Opens in new tab .<br>2:50 So sometimes it's number Discover how to work with numbers in Google Sheets and beyond. Opens in new tab sometimes it's other things. We're converting it to a string Learn about string manipulation in Google Sheets and Apps Script. Opens in new tab and then we're returning this. We go up to deploy new deployment if you've never deployed it before.<br>3:02 Uh, you will have to execute as Discover how to set permissions when deploying Google Apps Scripts. Opens in new tab yourself anyone should have access and click deploy. It's going to give you a URL.<br>3:12 If you go to an incognito tab and use that URL, you should get just the number Discover how to work with numbers in Google Sheets and beyond. Opens in new tab . This is 8.53.
This is exactly what we want.<br>3:22 Uh, and you can test it this way. Go to an incognito window. Take that exact URL. Just paste an URL bar and you're going to get an error Troubleshoot common errors encountered in Google Sheets. Opens in new tab bar.<br>3:29 So how does our website get that? Well, let's go back to our code and I'll show you. So this is uh the headline, current net promoter score and we're using a p div here.<br>3:44 Uh or paragraph and we're calling it ID number Discover how to work with numbers in Google Sheets and beyond. Opens in new tab . And then in this script we're saying hey go to this URL which is the web app URL Learn how to deploy and use web app URLs in your projects. Opens in new tab that we just deployed.<br>3:54 We copied that, put it right here. We're saying fetch that URL.
Then take the response. And turn into text. Get the text of that.<br>4:05 And then we are going to the text is the doc. So now we're creating a document.createElementSpan within this ID number Discover how to work with numbers in Google Sheets and beyond. Opens in new tab .<br>4:14 Okay. And we're up pinned. Name that to here to that number Discover how to work with numbers in Google Sheets and beyond. Opens in new tab . We're setting the attribute. This is just setting some uh styling here.<br>4:25 Again, you can change this if you use some other CSS other than tailwind. And this is just the top section.<br>4:32 Okay, we're just getting that number Discover how to work with numbers in Google Sheets and beyond. Opens in new tab .
I've shown you that before in another video where Understand how to use query and where clauses in Google Sheets. Opens in new tab you embed a number Discover how to work with numbers in Google Sheets and beyond. Opens in new tab on sheet or you embed a headline in a website or the webpage.<br>4:43 This is all fairly much the same. But what about this? Other section down here. How likely are you to recommend better sheets in these buttons?<br>4:52 So what we're doing here is we just have again paragraph, a little div here, a little formatting Find out how to format your data in Google Sheets for better presentation. Opens in new tab of those text.<br>5:01 And then we're using Ruby to say create tenling.
Links one through ten where Understand how to use query and where clauses in Google Sheets. Opens in new tab the link is, it's the form URL Learn how to generate and use form URLs for Google Forms. Opens in new tab and it's a pre-filled form.<br>5:11 So you can get this link by going to your form. Let's actually go to our form, tools, manage form, go to live form and click this edit button or you can always edit the form.<br>5:26 Okay. Over here in the three buttons here we're get pre-filled link and we're just gonna put a number Discover how to work with numbers in Google Sheets and beyond. Opens in new tab , actually let's put number Discover how to work with numbers in Google Sheets and beyond. Opens in new tab 10 here, get link and what we're getting is a URL and I'll show you that here.<br>5:44 We'll create an HTML URL.
So this URL is the form forms Learn about Google Forms and how they can be integrated into your projects. Opens in new tab your URL all the way up to view form and this probably looks normal.<br>5:57 This view form. It then has this and entry dot and a number Discover how to work with numbers in Google Sheets and beyond. Opens in new tab here equals 10. So this URL in totality is saying entry dot this entry number Discover how to work with numbers in Google Sheets and beyond. Opens in new tab .<br>6:11 So unique Discover how to find unique values in your data sets. Opens in new tab entry put number Discover how to work with numbers in Google Sheets and beyond. Opens in new tab 10. So let's look at that in an incognito window. It is already pre-filling 10. So if we take that last element 10, change it to a 4.<br>6:22 It's gonna pre-fill 4 in. So now any number Discover how to work with numbers in Google Sheets and beyond. Opens in new tab we put in here, at least 1 through 10, it's going to pre-fill that URL.<br>6:30 Uh sorry pre-fill that form from that URL.
Cool so that's what we're doing here is we're saying take this iteration Understand iteration in programming and how to apply it in your scripts. Opens in new tab 1 through 10 and iterate through all- of 10 of them create 10 links, uh create the little hover, uh shadows, there's some gaps here to just form these buttons here.<br>6:53 But that's what the Ruby is doing in this case. And you can do that in any number Discover how to work with numbers in Google Sheets and beyond. Opens in new tab of other programming for um languages as well.<br>7:03 But that shows you that We're just going to iterate through this URL, this pre-filled link. So we're using pre-filled links here.<br>7:13 We're using uh embedding uh web app URL Learn how to deploy and use web app URLs in your projects. Opens in new tab and a pretty simple one too.
I have to say if we go back up to extensions code.<br>7:22 This is fairly pretty much two lines of code in here. We're using the function Understand functions in Google Sheets and how to use them effectively. Opens in new tab do</div>