Sending data from Construct 2/3 to Google Spreadsheet

  • 26 favourites

Attached Files

The following files have been attached to this tutorial:



Download now 172.42 KB


6,636 visits, 10,113 views


This tutorial hasn't been translated.



This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Sometimes you may need to collect data from players. This could be their scores, game statistics, feedback, survey answers or anything else.

There are many ways you can transmit this data - you can send it to MySQL database, upload to Firebase, email etc. Not many people know this, but it's also possible to send it to Google Spreadsheet.

DISCLAIMER: The method described below is not secure! The data is not encrypted or protected in any way, and anyone who has the web app link can send "fake" data to your spreadsheet. So don't use it for any sensitive information!

If you have multiple Google accounts, I recommend signing off all of them except just the one you want to be associated with this spreadsheet.

1. Open Google Sheets and create a new document. Enter the name of the document, for example "High scores".

Make sure your sheet name is "Sheet1" - this is important if you are using Google Docs in a language different from English.

Add the following headers into the first row:

Select the entire third column and click Format -> Number -> Date time.

2. Click Tools -> Script Editor to create a new Google Apps Script

Rename it to "Submit Data to Google Sheet" or something similar.

Remove all existing code, open the file attached to this tutorial, unzip it and paste its content into the window.

Save changes.

3.Click Run -> Run Function -> setup to run the setup() function.

In the Authorization Required dialog, click on Review Permissions.

If you see this warning, click "Advanced" and then select "Go to <your script name> (unsafe)".

Confirm all permissions and click "Allow".

4. Click Publish -> Deploy as web app.

Make sure to select "Project version=New" every time you publish it!

Set "Who has access to the app: Anyone, even anonymous".

In the next dialog copy the "Current web app URL", you'll need it later:


Now open the CAPX project attached to this tutorial.

Paste the copied web app url into the global variable web_app_url.

Run the project and test:

Congratulations, you did it!

If you wish to send more data fields, simply add more parameters to the url and edit these lines in the script:

After making these changes in the script make sure to deploy the web app again and select "Project version=New".

And finally, if you want to read the data back from the spreadsheet, please see this tutorial: Create Online Database with Google Spreadsheet.



Download now 172.42 KB

  • Order by
Want to leave a comment? Login or Register an account!
  • Hi!dop2000 Thank you for tutorial! But I get this error when press button "Cannot call method getLastRow" How I can fix it?

    EDIT: False alarm, it works! If non-english language is set in your Google Sheets, then you should rename your sheet to "Sheet1"

  • how do i replace a pre-existent data in the google sheet?

  • how do i replace a pre-existent data in the google sheet?

    • You can manually erase this data. Or if you need to do this with the script, edit this line:

      var nextRow = sheet.getLastRow()+1;

      • i don't know to much about JavaScript, if you can make an example it would be so helpful to me, and sorry for the trouble.

        • It's not JavaScript, it's in the script which is attached to the tutorial. Find that line in the script and change it - remove "+1" or something like that.

  • Hi dop2000

    Thanks for this tutorial, works great.

    I'm just using it for 1 column to store player names, do you know how I can check if the name is unique? I'm getting lost in stack exchange!

    Thanks for any help


    • I'm not sure how to do it with the gscript, but you can read the table data to Construct first and check if the name is unique before submitting it.

  • I do literally what the tuto said but in construct show me the same error

    {"result":"error", "error": {}} and I don't find where my fault, so please help me to solve this problem.


  • Load more comments (43 replies)