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!
- WarrinRichinsCommunity Member
I'm going to speak in non-technical terms because that is what I understand best.
the two things that I want on my spread sheet are 1- students name and 2- students score on the quiz (game)
and possibly 3- how much time it took.
So I have made my spreadsheet and named the columns Student name, students score.
I have also followed the other directions but now my question is-
Where? and at what point? and how do I specify that these are the variables I want to have on the spreadsheet?
Thank you!
- KateRobertson1Community Member
Hi Warrin,
Firstly, you need to create variables called 'Student name' and 'students score' in Articulate. Then you create a trigger to execute the the following javascript (replace 'current web app url' with your own url as described in the original method':var player = GetPlayer();
$.ajax({
url:
"Current web app URL",
type: "POST",
data: {"Student Name": player.GetVar("Student name")
, "students score": player.GetVar("students score")},
success: function(data)
{
console.log(data);
},
error: function(err) {
console.log('Error:', err);
}
});
return false;Hope that helps?
You're finding good threads Warrin and hopefully someone will have the answer/solution you are looking for.
- MichaelMengeCommunity Member
Hi there. This is really a great solutions and works almost fantastic for me. Sadly, just almost ;(
I got the script to send the name which a user enters at the beginning of the module to the google sheet. However scored points, calculated by answering a number of questions, are not transfered. If I change the field to receive the "Name" value (instead of "Points") it works fine. So I suppose it's just related to the variable not being mapped correctly? The quiz result slide does correctly show scored points.
Any help would be appreciated :)
data: {"entry.1309481895" :player.GetVar("Name"), "entry.774564750":player.GetVar("Points")},
- MaricelMedina-MCommunity Member
Hi,
I am testing this code and I am getting the following error:
XMLHttpRequest cannot load https://script.google.com/macros/s/AKfycbzrHjkMi9boQEsDCwNHdfXYZe5fTGx43n3xtHNhPxv4LYlOvOg/exec. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://s3.ca-central-1.amazonaws.com' is therefore not allowed access. The response had HTTP status code 401.
1. My storyline is hosted in AWS
2. My google doc is in GoogleDocs
I have made everything public ... Any advice?
- kristianchar230Community Member
My guess is that your browser is blocking the content because of CORS (Cross-Origin Request Sharing). You could try opening the link in IE and set your browser to display insecure content.
You should be able to fix the problem by following the instructions outlined here: https://stackoverflow.com/questions/10636611/how-does-access-control-allow-origin-header-work
- TroyWyattCommunity Member
Is this proccess still working with google spreadsheets, I have tried countless times checking and rechecking code, variable names , column names and it should all be working, but data just doesn't hit the spreadsheet
- SarahPoirierCommunity Member
Can this be done with Storyline 1? Or do I need a newer version?
- NormanLamont1Community Member
When I did it, it was with SL1, I’m fairly sure.
- kristianchar230Community Member
Should be doable in any version of SL
- SarahPoirierCommunity Member
Ok thank you!
- FloorSonneveldCommunity Member
@Sarah I have used this example: https://helpdesk.courseware.nl/hc/en-us/articles/205740482-Articulate-Storyline-Export-to-Google-Drive
I tried every step from this page, but it still was not working, when I did use the link above it worked for me, so you could try this!
Thanks Floor for sharing that here