Forum Discussion
Exporting Variables into a Google Spreadsheet
Having read this post on how to export variables to be read in a google spreadsheet, I set about trying to get this working in my project, I soon ran into problems, I just could not get it to work as google have changed some of the ways they work their drive documents.
So, after a LOT of google searching and testing various methods, plus reading this article, I came up with the following method which is a combination of the two articles – and it works, hurrah!
1. Create a new google spreadsheet and change the sheet name (lower left hand corner) to DATA. Make sure your column names are the same as the variables you want to export (exactly matching case)
2. Find out your spreadsheet ‘key’ by looking in the address bar, the key is the long series of letters and numbers after /d/ and before /edit:
Eg: https://docs.google.com/spreadsheets/d/1gF0QCNA1TZCNY3qr2zNpWKQ8r43D39o-nqz56c7cQUs/edit#gid=1283040575
Key = 1gF0QCNA1TZCNY3qr2zNpWKQ8r43D39o-nqz56c7cQUs
3. Open the script editor (Tools ==> Script Editor) in your spreadsheet and paste the script from the attached file (I have copied and pasted this script and just kept in all the instructions)
4. There are two places in the script where it says “KEY” – copy and paste your key into these two places, between the “”.
5. Run the setUp script twice (Run menu). The first time it will ask for permission to run (grant it), then the second time you select to run it you won't get any popup indication it has run.
6. Go to Publish > Deploy as web app, enter Project Version name and click 'Save New Version', set security level and enable service (most likely execute as 'me' and access 'anyone, even anonymously).
7. Copy the 'Current web app URL' and paste in a notepad file to keep safe.
8. In Articulate, add a trigger to run javascript and use the following code, replacing “Current web app URL” with your URL you copied in the previous step (in””):
var player = GetPlayer();
$.ajax({
url:
"Current web app URL",
type: "POST",
data: {"Name": player.GetVar("Name")
, "Rating1": player.GetVar("Rating1")
, "Rating2": player.GetVar("Rating2")
, "Rating3": player.GetVar("Rating3")
, "Rating4": player.GetVar("Rating4")
, "postRating1": player.GetVar("postRating1")
, "postRating2": player.GetVar("postRating2")
, "postRating3": player.GetVar("postRating3")
, "Postrating4": player.GetVar("Postrating4")},
success: function(data)
{
console.log(data);
},
error: function(err) {
console.log('Error:', err);
}
});
return false;
9. Publish your articulate project – you need to host it somewhere like SCORM cloud or a LMS. When it has finished publishing click to open the files and edit the story.html and story_html5.html files – add the following line in under the line <!-- version: X.X.XXX.XXX --> or somewhere after <head>:
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
10. Go back to articulate and click ‘zip’ – then publish your zip file and hopefully it will work!
This isn’t for the faint hearted but it is so worth it if you can get it working! Good luck!
- mahdibaghiniCommunity Member
Hi, I run all the steps to send the variables from the storyline to the Google Sheet, but the information is not transferred. Please, if possible, check and report my problem. Thanks
- SevanaMonti-3f1Community Member
Hi team,
Does anyone know if this solution is possible using microsoft office excel sheet rather than a google sheet? Just not sure with the 'key' in the address and script editor functions.
Thanks team
- StephenGoreyCommunity Member
This functionality does not work at all anymore. Google changed security features for sheets about a year ago and the code here won't work anymore. There is a company called Clue labs who provide similar but paid service. https://cluelabs.com/elearning-widgets
- DarrenHeath-ef0Community Member
https://www.littlemanproject.com/posts/javascript-google-sheets/
This solution does work, and is free. The tutorial and video only show it sending 1 variable but with some additions to the JS code in the SL module and some adjustment in the web app script you can send multiple variables to your Google Sheet.Thanks Little Man Project for this!!
- JersonCampos-17Community Member
@Darren, would you mind sharing what you did? I've tried to export multiple variables and haven't had any success.
- HerveLihouck-15Community Member
Bonjour,
Quelqu’un a trouvé une solution pour exporter plusieurs données de Storyline vers google sheet, Mes anciennes créations fonctionnent encore, mais plus moyen de transférer les données sur mes nouvelles création?
Je ne suis pas un spécialiste des java et autre.
Quelqu’un a une solution?
Merci à tous de votre aide
- HerveLihouck-15Community Member
Bonjour,
solution trouvée, voir les explications:
bonne journée
- JoleneDonahue-9Community Member
- SteveFlowers-75Community Member
Your script endpoint works. What does your code within storyline look like?
- SteveFlowers-75Community Member
Weird. It wouldn't allow my reply. Your script endpoint works fine. I pushed two submissions into your spreadsheet. What does your Storyline JS look like?
- JoleneDonahue-9Community Member
Copied directly from the forum discussions and then the KEY, variables and URL updated.
Script 1
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.src = '//code.jquery.com/jquery-1.11.0.min.js';
script.type = 'text/javascript';
head.appendChild(script)Script 2
var player = GetPlayer();
//PLACE YOUR WEB APP URL
WEB_APP_URL = "https://script.google.com/macros/s/AKfycbx8Jx0m_R5XaGKIbOBcbQPZWwWjmPyXeiAN1E4HGdFfcsrwiuG-eiYWOfqpz9ae30X_rQ/exec";
// STORE ARTICULATE STORYLINE VARIABLES
// "Columnname_Google_Spreadsheet" : player.GetVar("Name_Storyline_Variable")
// ATTENTION: Use a comma if you use multiple Storyline variables
storyline =
{
"date" : new Date().toJSON().slice(0,10), //STORE DATE
"FirstLastName" : player.GetVar("FirstLastName")
}Script 3
//DELAY SO JQUERY LIBRARY IS LOADED
setTimeout(function (){
//Export to Google
$.ajax({
url: WEB_APP_URL,
type: "POST",
data : storyline,
success: function(data)
{
console.log(data);
},
error: function(err) {
console.log('Error:', err);
}
});
return false;
}, 1000);
- SteveFlowers-75Community Member
Here's a screenshot of the URL that I used to get that data into the sheet.