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!
- NormanLamontCommunity Member
Success!
This time I overwrote the function which probably explains why it works now. I must have had function calls within a function call previously.
I'm finding it works - and I'm delighted and grateful - but when I hit the send button I get a popup saying [object][object] Does anyone know how to get rid of that? Is it maybe caused by this line in the Storyline script?
success: function(data)
{
alert(data);
} - NormanLamontCommunity Member
Sorry for learning out loud here, but I hope it's useful to others who come along later. The popup is caused by that part of the code. I commented out the alert and it no longer appeared. The data still transferred to the spreadsheet.
success: function(data)
{
//alert(data);
} - NormanLamontCommunity Member
Thanks for a very valuable set of instructions. That's been really helpful.
- NormanLamontCommunity Member
Just a thought but could you receive records for more than one course by having other sheets and calling them something other than 'DATA' (and changing the script accordingly)?
- LauraBrunningCommunity Member
Hi, thanks for replying so quickly. I'm driving myself crackers here! I've still not managed to do it though (my technical-ness isn't great) :(
I have tried putting the write to header trigger right at the beginning and the write to google one right at the end of the project (so it take the time to get from one to the other) - I assumed this would be the same as having it on different layers, but I could be wrong there!
I have to admit, I didn't fully understand your second post, but I have tried putting it before the write to header code from earlier and that didn't work, but I think I'm not writing the code properly. I'll have another crack at it later.
Cheers for your help!
- SteveFlowersCommunity Member
Happy to have a look if you have a published output or story file to share.
- JessicaAdams-ebCommunity Member
It worked it worked it FINALLY worked!!!!!!
Three straight days 8 hours per day and finally FINALLY I can tell my supervisor that "Yes, we can send data to an online spreadsheet from Storyline without using the LMS."
I've looked at so much source code I thought I'd be sick. But it FINALLY worked! Thank you all so much, if it weren't for this thread I'd never have done it!
Just thought I'd share. :D
Thanks for sharing Jessica :) We can feel your relief in your post!
- RobertKankelborCommunity Member
How do you do step 9?
- MichaelBurns-04Community Member
Hey Robert, you'll find the output folder on your computer, which contains the story.html file along with the html5 file. You can open these with Notepad or another plaintext editor.
Once you have them open, copy and paste the text from step #9 after the < head> tag, and save. Hope that helps.
- RobertKankelborCommunity Member
Perfect...yes! Thank you Michael!