problem in send data from storyline to googlesheet

Jul 26, 2022

Hello. I have searched a lot about sending variables from Storyline to Google Sheet( with app script and without app script). But so far I have not succeeded in doing this. I don't know where the problem is. Please let me know if you have an address that explains more.I have already successfully done the same thing with App Inventor. Thank you.

 

14 Replies
Math Notermans

i use Google Functions to read, write and update data on Google Sheets.
https://developers.google.com/sheets/api

https://cloud.google.com/functions/docs/concepts/overview?hl=en-GB

On the Google Cloud you create functions for read, write and update in Node.js ... then you can call them easily from within Storyline.




Math Notermans

First mistake in your Storyline. JQuery is not loaded by default in Storyline360 anymore so you need to add it inline in the html or load it as WebObject before you can use jQuery. Oops im sorry...its on the first lines of code... not my preferable way... but lets see if it gets loaded properly.

Math Notermans

If you use the console for testing and checking your code you would notice that the error is in timing ( jQuery not loaded quickly enough ) or that the jQuery file wanted is not found...

error

As you can see in the console here... i get a error message: '$ is not defined'  All errors with $ point at jQuery. So it cannot find or load the jQuery library. Either because it isnot loaded when calling it, or because it cannot find the requested file. Gonna troubleshoot it a bit more.

A second attempt with better timing to ensure jQuery could load and its clear...the url is not correct. Here you can find the proper jQuery CDNS you need.
https://releases.jquery.com/jquery/

Math Notermans

So when checking on https://releases.jquery.com/jquery/ the code for properly injecting jQuery is like this:
<script src="https://code.jquery.com/jquery-1.1.1.js" integrity="sha256-6/6tEG91KdLJdvYQDRIjcmzsB4N/QQ92AmlTtBnSCUQ=" crossorigin="anonymous"></script>

So when you replace the code you used inside your script by this url...
you get another error...
e2
Now Storyline is trying to connect with your Google Sheet but due to CORS ( Cross Origin  Resource Sharing policy ) it is not allowed. This is on any browser nowadays. You have to ensure your calls are allowed cross browser else it will be denied access.

But as we seen in the code we copied from jQuery releases inthere is a setting that allows CORS access... 'crossorigin=''anonymous"' in combination with the sha-encryption.

This means if you add the jQuery in another way...either by WebObject or direct inline in the html with this scripttag... it probably will work.

<script src="https://code.jquery.com/jquery-1.1.1.js" integrity="sha256-6/6tEG91KdLJdvYQDRIjcmzsB4N/QQ92AmlTtBnSCUQ=" crossorigin="anonymous"></script>

Testing that now.