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!
Thanks Louise for popping back in here to share that!
- YoniHCommunity Member
This works for me when using Chrome but NOT Internet Explorer 9 (some people still use it!).
Does anyone know if/how to make it work with Internet Explorer 9 or above?
Cheers!
- JacintaPennCommunity Member
Some of my clients have just accepted now that if they want the better features they need to run it on Google Chrome or Firefox. Internet Explorer is being retired this year so its not keeping up with elearning tool demands.
Hi Yoni,
I'm sorry to hear that this doesn't work for you in IE9, but as Jacinta mentioned it's an aging browser so encouraging your users to update is a good recommendation. Since we don't support exporting variables to an excel document or Google spreadsheet I'll defer to the community for assistance.
- NormanLamontCommunity Member
Hi. I've been trying for a few hours to get this working but without success. I'm sure I've got everything correct in the code, but my spreadsheet doesn't update and I don't get any popup in the Storyline course confirming the data has been sent.
Can I just check a couple of things?
1) does this work in Storyline 1? My client isn't on v2 so I'm trying it in V1. I did try the Storyline 2 version Louise put up, substituting my my Google URL and variable names, but again nothing happened.
2) does the page that does the sending have to be a Quiz Results page? I've just been using an ordinary page. I set the values of the variables in the page, just for test purposes and attached the 'sending' script to a button.
I'm fairly sure of my syntax and have included the JQuery link in the header. I'm not hosting it on an LMS, just on a website, since the point of doing it is for a client who doesn't have an LMS.
The variable names definitely reflect the column headers in the spreadsheet. Any other stumbling blocks I should check?
- KateRobertsonCommunity Member
Hi Norman, I haven't tried it in SL1 but I do use it on a normal slide, i.e. not a results slide and it works well. Just a thought, have you made your google doc public? If it's not shared it won't work.
Louise, thanks for the updated code to avoid the [object] alert, I have pinched that!
- KateRobertsonCommunity Member
Steve - you really are a hero! I have just tried your JS to autoadd the JQuery library to my header so I didn't need to do any post-publish surgery - it WORKED! Hurrah! Thank you!
- NormanLamontCommunity Member
Hi. Thanks for the suggestions. I'm going to redo it from scratch and post the links here.
- NormanLamontCommunity Member
- NormanLamontCommunity Member
Another naive question while I'm at it. When I paste the text from your file, should I put it inside the function myfunction() { } that appears in the Script Editor, or overwrite it?