Trouble embedding Google Drive Scripts project in Google Sites

I’m having difficulty embedding my Google Drive Scripts project in Google Sites. When I try to do this, I receive an error message saying that the URL is not recognized as a valid Apps Script. Here’s a summary of the steps I followed:

  • I created a script project in my Google Drive.
  • I added a function called function doGet(e) { /* code */ }.
  • I published the script as a web app.
  • I copied the provided link for the script.
  • In Google Sites, I went to the edit mode and inserted a script using the Insert > Apps Script Gadget option.

However, when I paste the script’s link, I keep getting the message: This url is not recognised as a valid Apps Script. Where did I go wrong?

Additionally, I’m curious if it’s possible to run my Google Drive Script without adding the code directly to the site’s page. Can I execute it from various Google Sites pages while providing different parameters each time?

Thanks a lot for your help!

Michele

This happens all the time with Apps Script deployments. You can’t use the project URL from Drive - you need the actual deployment URL that Google gives you when you publish as a web app. Look for the one ending in /exec and use that in Google Sites. For your second question - yes, you can definitely run the same script from multiple pages with different parameters. Just pass them through URL query strings when calling your web app. Your doGet(e) function grabs these with e.parameter.yourParameterName. This way you’ve got one script handling different inputs from various pages instead of duplicating code everywhere.

This happens all the time with Apps Script and Google Sites. First, double-check you’re copying the deployment URL, not the script editor URL - they’re completely different and only the deployment one works with the Apps Script Gadget. Also make sure your script permissions allow the right people to run it (anyone, or anyone with the link). For your second question - yes, you can definitely run the same script from multiple pages with different parameters. Just set up your doGet function to handle different parameter combinations, then call the web app from various Sites pages by adding query parameters to the URL. Keeps everything in one place while giving you flexibility across your site.

hey, just checkin in! make sure u use the execution URL after publishing your script as a web app, not the editor link. and don’t forget to set the permissions right or it won’t work!