{"id":24969700,"url":"https://github.com/positivecrash/gridsome-plugin-google-sheets-post","last_synced_at":"2026-02-07T10:32:02.904Z","repository":{"id":57254192,"uuid":"416705207","full_name":"positivecrash/gridsome-plugin-google-sheets-post","owner":"positivecrash","description":"This Gridsome plugin for posting any data from form to Google Sheets","archived":false,"fork":false,"pushed_at":"2024-12-08T21:28:55.000Z","size":852,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-08T12:58:21.592Z","etag":null,"topics":["contact-form","google-script","google-sheets","gridsome","gridsome-plugin"],"latest_commit_sha":null,"homepage":"","language":"Vue","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/positivecrash.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-13T11:08:20.000Z","updated_at":"2024-12-08T21:28:58.000Z","dependencies_parsed_at":"2022-08-31T08:21:26.344Z","dependency_job_id":"ede9638b-a381-4b09-acfa-36d25bbdfb6b","html_url":"https://github.com/positivecrash/gridsome-plugin-google-sheets-post","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/positivecrash/gridsome-plugin-google-sheets-post","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/positivecrash%2Fgridsome-plugin-google-sheets-post","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/positivecrash%2Fgridsome-plugin-google-sheets-post/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/positivecrash%2Fgridsome-plugin-google-sheets-post/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/positivecrash%2Fgridsome-plugin-google-sheets-post/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/positivecrash","download_url":"https://codeload.github.com/positivecrash/gridsome-plugin-google-sheets-post/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/positivecrash%2Fgridsome-plugin-google-sheets-post/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29192646,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T07:37:03.739Z","status":"ssl_error","status_checked_at":"2026-02-07T07:37:03.029Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["contact-form","google-script","google-sheets","gridsome","gridsome-plugin"],"created_at":"2025-02-03T14:51:38.874Z","updated_at":"2026-02-07T10:32:02.890Z","avatar_url":"https://github.com/positivecrash.png","language":"Vue","funding_links":[],"categories":[],"sub_categories":[],"readme":"- This plugin for posting any data from form to Google Sheets.\n- Useful for contact forms etc.\n- No limitations for form element.\n- Built-in [hCaptcha](https://github.com/hCaptcha/vue-hcaptcha/tree/master)\n\n## Get started\n\n### `gridsome.config.js`\n\n```js\nmodule.exports = {\n  plugins: [\n    {\n      use: \"gridsome-plugin-google-sheets-post\"\n    }\n  ]\n}\n```\n\n## Usage\n\nWith built-in submit events, hCaptcha and auto forming request\n\nYour Vue template:\n```html\n\u003cgsp-form :gscriptID=\"gscript\" :siteKey=\"siteKey\" @gsp-beforesubmit=\"beforeSubmit\" @gsp-onsubmit=\"onSubmit\" @gsp-oncaptchanotverified=\"captchaError\"\u003e\n    \u003cinput type=\"text\" placeholder=\"Your data\" data-gsp-name=\"data-name\" :data-gsp-data=\"data\" v-model=\"data\"/\u003e\n    \u003cbutton\u003eSend\u003c/button\u003e\n\u003c/gsp-form\u003e\n```\n```js\n\u003cscript\u003e\nexport default {\n  \n    data() {\n      return {\n       \n        gscript:  process.env.GRIDSOME_GSCRIPTID,\n        siteKey:  process.env.GRIDSOME_SITEKEY,\n\n        data: ''\n\n      }\n    },\n\n    methods: {\n        captchaError() {\n          /* react on captcha not verified */\n        },\n\n        beforeSubmit() {\n          /* do smth here for ui, e.g. show loading */\n\n          if(responce === 'captcha error') {\n              /* Captcha error handling. Usually this error can occur when user has no internet connection */\n              return;\n          }\n        },\n\n        onSubmit(responce, submition) {\n          /* this function only for additional actions, form submitting in this example is executed by built-in component */\n\n          /* responce - how was submition done. */\n          /* submition - posted submition, might be usuful for a code debugging */\n\n          if(responce === 'success') {\n            /* show success */\n          } else {\n            /* show error */\n          }\n        }\n    }\n}\n\u003c/script\u003e\n```\n\nWatch result with `$response`\n\n\n## Forming Google Sheet\n\nYou may use script template below and follow the steps:\n\n1. Create Google Sheet doc in your account: first column named **sn** + columns named as your fields in form + column named **timestamp**. You may rewrite script and use other tech columns as you like.\n2. Open Apps Script and write script for posting data in doc + you can send email notifications for any person (admin or user). See example below.\n3. Than deploy script. If you use script from example below: choose **setup** function and run this; choose **doPost** and Deploy it. Give writes for 'all' so your website can write to the sheet.\n4. Copy script id from deploying and setup [environmental variable](https://gridsome.org/docs/environment-variables/)\n\n**Script example:**\nPlease watch sendEmail function, you need to edit it according to your data. Also you can choose not to send email, so just delete this function.\n\n```js\nfunction doPost(e){\n  return handleResponse(e);\n}\n\n//  Enter sheet name where data is to be written below\nvar SHEET_NAME = \"Sheet1\";\n\nvar SCRIPT_PROP = PropertiesService.getScriptProperties(); // new property service\n\nfunction handleResponse(e) {\n  // Google the LockService prevents concurrent access overwritting data\n  // [1] http://googleappsdeveloper.blogspot.co.uk/2011/10/concurrency-and-google-apps-script.html\n  // we want a public lock, one that locks for all invocations\n  var lock = LockService.getPublicLock();\n  lock.waitLock(30000);  // wait 30 seconds before conceding defeat.\n  \n  try {\n   \n    // next set where we write the data - you could write to multiple/alternate destinations\n    var doc = SpreadsheetApp.openById(SCRIPT_PROP.getProperty(\"key\"));\n    var sheet = doc.getSheetByName(SHEET_NAME);\n    \n    // we'll assume header is in row 1 but you can override with header_row in GET/POST data\n    var headRow = e.parameter.header_row || 1;\n    var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0];\n    var nextRow = sheet.getLastRow()+1; // get next row\n    var row = []; \n    // loop through the header columns\n    for (i in headers){\n      if (headers[i] == \"timestamp\"){ // special case if you include a 'Timestamp' column\n        row.push(new Date());\n      } else if(headers[i] == \"sn\") {\n        row.push(sheet.getLastRow());\n      } else { // else use header name to get data\n        row.push(e.parameter[headers[i]]);\n      }\n    }\n    // more efficient to set values as [][] array than individually\n    sheet.getRange(nextRow, 1, 1, row.length).setValues([row]);\n    \n    //send email\n    sendEmail(e.parameter);\n    \n    // return json success results\n    return ContentService\n          .createTextOutput(JSON.stringify({\"result\":\"success\"}))\n          .setMimeType(ContentService.MimeType.JSON);\n  } catch(e){\n    // if error return this\n    return ContentService\n          .createTextOutput(JSON.stringify({\"result\":\"error\", \"error\": e}))\n          .setMimeType(ContentService.MimeType.JSON);\n  } finally { //release lock\n    lock.releaseLock();\n  }\n}\n\nfunction setup() {\n    var doc = SpreadsheetApp.getActiveSpreadsheet();\n    SCRIPT_PROP.setProperty(\"key\", doc.getId());\n}\n\nfunction sendEmail(data) {\n\n  var email = ''; // automatic email responce to user\n  var emailFrom = '';\n  var emailAdmin = ''; // notification for admin\n\n  var data = '';\n  var timestamp = new Date();\n  var adminBody = '';\n  var userBody = '';\n  var userTitle = '';\n\n  for (let key in data){\n   if(data.hasOwnProperty(key)){\n     if (key === 'data') { name = data[key]; }\n     if (key === 'email') { email = data[key]; }\n   }\n  }\n\n  adminTitle = 'New form apply';\n  adminBody = 'New form apply on website';\n  userTitle = 'Your application';\n  userBody = 'Your apply has been sent';\n\n  if (email != '') {\n    GmailApp.sendEmail(emailAdmin, adminTitle, '', {\n      name: 'yourwebsite.com',\n      from: emailFrom,\n      htmlBody: adminBody\n    });\n    \n    GmailApp.sendEmail(email, userTitle, '', {\n      name: 'yourwebsite.com',\n      from: emailFrom,\n      htmlBody: userBody\n    });\n  }\n}\n```\n## TODO\n\n- Move to another captcha\n- Make local registration of component possible\n\n\n## Troubleshoting\n\nIf you have any troubles, [create issue](https://github.com/positivecrash/gridsome-plugin-google-sheets-post/issues) on Github","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpositivecrash%2Fgridsome-plugin-google-sheets-post","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpositivecrash%2Fgridsome-plugin-google-sheets-post","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpositivecrash%2Fgridsome-plugin-google-sheets-post/lists"}