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!
- MichaelHinzeCommunity Member
I have used Google spreadsheets several times in the past to store Storyline variables. I know what the process is and I never had any problems until now. With a new spreadsheet and new Storyline project I now get an error when I run the published content. In the browser console, I get :
"Failed to load https://script.google.com/macros/u/0/s/../exec: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://...com' is therefore not allowed access. The response had HTTP status code 404."
Note: I replaced the real URL with ..
After some research this seems to be a cross domain security issue (the SL content runs on one domain, while the Google spreadsheet is hosted on another). BTW, this also happens with Captivate-based content, so my guess is the issue is related to the "the Google end".
Does anyone have insights on the root cause and how to fix this issue?
- SteveFlowersCommunity Member
Hi, Michael -
I stopped using the script-based submission for a variety of reasons awhile ago. Instead, I just use the formResponse target that the normal form uses with an AJAX post. This tends to work every time for me. I use the "Get Prefilled Link" feature to discover the expected form fields.
https://docs.google.com/forms/d/e/1FAIpQLSewmIMASgsR78EKGSEG1Y81TgPHJ2YjaunE2d4F6C5l9v2nrw/formResponse?entry.1632817179=First&entry.764465594=Second
- MichaelHinzeCommunity Member
Hi Steve,
thanks for the info. It's funny, I had used fieldIDs for my very first test project. It did work fine but it felt like a hack...having to dig up the IDs, etc. I'll give it a try. Back to the future!
- ClaudineCaroCommunity Member
Steve, I'm very interested in this. My goal is to do the following:
- Pull email address from LMS into Storyline360
- Send email address from Storyline to Google Form -> Google Spreadsheet on course completion trigger
- Use Zapier to collect email address and send an email to the learner.
I've pulled in the email address from the LMS to Storyline. But I can't get it to spit out to the Google Form.
I used the script you posted several years ago. Now I'd like to use your formResponse target but I don't know how to change my javascript.Can you help me figure it out?
The SL course is hosted on ScormCloud
https://cloud.scorm.com/sc/InvitationConfirmEmail?publicInvitationId=91fa6f1b-fd93-4f16-bfe4-fdc71f01b8c4
thanks-Claudine
- KarinaMartinez-Community Member
This coding is working perfectly in the LMS but i wanted to use this in a course published in a web site and it didn't work. I had to embed the google form as an web object, but i don't like how it looks...is there another way to do it? do i have to change the code in the javascript?
- CamilleBonnetCommunity Member
Hi,
I set up my google spreadsheet and it is working perfectly except for the Results.ScorePoints variable and for a boolean variable that I change through a checkbox in the storyline.
Does anyone know how to export this Results.ScorePoints variable? And what happens to a variable associated to a checkbox?
- PhilMayorSuper Hero
You cannot send results variables but you can assign the value of the results to another variable in storyline and send that.
The Boolean should send, might be a naming issue.
- CamilleBonnetCommunity Member
Thank you very much Phil, I checked and I had forgotten to add the boolean variable into the javascript code.
As for the result variable, I'll re-test it now that it is in a new variable. At least, I discovered something thanks to you :)
- ReginaSaenz-ba7Community Member
It seems that some of the set up for this have possibly changed a bit since this thread was first created! I was able to get all the way to coding my google sheet, and triggering to execute javascript, but now I am finding difficulty in actually manipulating the code in the published version of the course. Now I will say, I dont have an LMS, so I published for the Web. Can someone help me out in updating some of the step by step instructions or direct me were some updated instructions are?
- PulkitMalhotraCommunity Member
Hi Kate,
i was trying to use this example on my story but i always get a message saying
Script function not found: doGet
Can you help me out with it?
- NicolePierceCommunity Member
Hi, I am trying to use this in a current Storyline project. Could you elaborate on the 9th step? How do you edit the story.html and story_html5.html files?
- MicheleBlascoviCommunity Member
Hi!
I'm doing a survey to test the skills of about 150 people and then offer them lessons according to their needs. To do this I need to know exactly what they answer to each question, and not only if they answer correctly.
Do you guys think this method will work also to export quiz answers? Is there the possibility to use quiz answer as they were variables?
Can you help me out with it?
- LizzieAngellCommunity Member
I found this video - it gives all the instructions clearly and in the right order, and I got it all working no problem:
https://www.youtube.com/watch?v=5V2pvtFGeyY
you should be able to do your quiz using this to record the results