Forum Discussion
Articulate Storyline: Export to Google Drive
On the Articulate user days in Utrecht (2015), we held a session about exporting Articulate Storyline variables to Google Drive (Spreadsheet). This export is achieved via JavaScript (jQuery).
Use the button Source to download the Storyline project. If you want the same lay-out as the example above, please install the following fonts (see source file):
- flaticons-stroke.ttf
- fontawesome-webfont.ttf
Why do you want to make an export to Google Drive?
- No LMS (or database) available;
- Store more information than just the test results. You can export all Storyline variables to Google Drive.
Why using Javascript?
Besides using Javascript it's also possible to embed a Google form as WEB object. This is a lot easier than using Javascript.
We have chosen for Javascript because we would like the ability to change the appearance of the form. In addition, we want to collect data across multiple slides and then store them in Google Drive.
UPDATE 2017-06-06:
There is also an article available for importing records of a Google Spreadsheet into Storyline:
Articulate Storyline: Import from Google Drive
UPDATE 18-10-2018: PROBLEMS WITH NEW SPREADSHEET, TRY TO USE A TEMPLATE
Google changed somthing within the mechanism of storing variables into a Google Spreadsheet. Creating a new spreadsheet can give you problems for storing variables. Before you try the steps below, please use a template:
Go to the page below and use the button Use this template:
https://drive.google.com/previewtemplate?id=1vrqb9ykwCSxzjcBIpYO7P9AXPyh37J3HviSwhZvYc_U&mode=public
And go further with step 4 below!
Export to Google Drive
The export consists of several steps. Some steps take place on the side of Google. For these steps you will need a Google account. The remaining steps take place in Articulate Storyline.
Below you'll find the steps to create the export to Google Drive:
1. Login with your Google account
Go to the page below and login with your credentials:
https://docs.google.com/spreadsheets/
2. Create a new spreadsheet
Click on the Plus-sign (+) to create a new spreadsheet.
3. Rename the sheet to DATA
Give the spreadsheet a title and change the name of the sheet to DATA.
4. Add extra columns
Add extra columns you would like to use. Probably these columns will have the same name as the variables in Articulate Storyline. As example: the column names name, email and message like in the source project.
You can add the column date in the spreadsheet, if you would like to save the date when the form is sent to Google.
The column names needs to be identical to the variable names in Articulate Storyline. The column names are case sensitive.
5. Copy the ID of your form
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: Like:
https://docs.google.com/spreadsheets/d/1AzBuim89ma_ght1-O14cksVzXrQL5Vh4XnRqY9OM_gc/edit#gid=0
The KEY will be = 1AzBuim89ma_ght1-O14cksVzXrQL5Vh4XnRqY9OM_gc
Save this KEY in a Notepad file to keep safe, or other application, you will need this ID in step 8.
6. Open the Script Editor
Open the script editor Tools, Script Editor.
7. Paste custom script
If you are using the template, then you can skip this step. The code is already in the template available. If not, paste the script below, which is needed for importing the Storyline variables into this spreadsheet:
// 1. Enter sheet name where data is to be written below
var SHEET_NAME = "DATA";
// 2. Enter the KEY of your form
var KEY = "KEY"
// 3. Run > setup
// 4. 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)
// 5. Copy the 'Current web app URL' and post this in your form/script action
// 6. Insert column names on your destination sheet matching the parameter names of the data you are passing in (exactly matching case)
var SCRIPT_PROP = PropertiesService.getScriptProperties(); // new property service
// If you don't want to expose either GET or POST methods you can comment out the appropriate function
function doGet(e){
return handleResponse(e);
}
function doPost(e){
return handleResponse(e);
}
function handleResponse(e) {
// shortly after my original solution Google announced the LockService[1]
// this prevents concurrent access overwritting data
// [1] http://googleappsdeveloper.blogspot.co.uk/2011/10/concurrency-and-google-apps-script.html
// we want a public lock, one that locks for all invocations
var lock = LockService.getPublicLock();
lock.waitLock(30000); // wait 30 seconds before conceding defeat.
try {
// next set where we write the data - you could write to multiple/alternate destinations
var doc = SpreadsheetApp.openById(SCRIPT_PROP.getProperty(KEY));
var sheet = doc.getSheetByName(SHEET_NAME);
// we'll assume header is in row 1 but you can override with header_row in GET/POST data
var headRow = e.parameter.header_row || 1;
var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0];
var nextRow = sheet.getLastRow()+1; // get next row
var row = [];
// loop through the header columns
for (i in headers){
if (headers[i] == "Timestamp"){ // special case if you include a 'Timestamp' column
row.push(new Date());
} else { // else use header name to get data
row.push(e.parameter[headers[i]]);
}
}
// more efficient to set values as [][] array than individually
sheet.getRange(nextRow, 1, 1, row.length).setValues([row]);
// return json success results
return ContentService
.createTextOutput(JSON.stringify({"result":"success", "row": nextRow}))
.setMimeType(ContentService.MimeType.JSON);
} catch(e){
// if error return this
return ContentService
.createTextOutput(JSON.stringify({"result":"error", "error": e})) .setMimeType(ContentService.MimeType.JSON);
} finally { //release lock
lock.releaseLock();
}
}
function setup() {
var doc = SpreadsheetApp.getActiveSpreadsheet();
SCRIPT_PROP.setProperty(KEY, doc.getId());
}
8. Paste your key
There is one place in the script where it says var KEY = "KEY". Copy and paste your key between the "".
9. Run the script
Run the script via Run, Run function, setup. The first time you run the script it will ask for permission to run. You will need to grant it. If you run the script for a second time you won't get any popup. This is an indication it has run successfully.
10. Deploy a web app
Go to Publish, Deploy as web app. Enter a project name (optional) and set security level. Choose for Me and access Anyone, even anonymously. Click on the button Deploy to create the web app.
11. Copy the Current web app URL
Copy the 'Current web app URL' and paste it in a Notepad file to keep safe.
Example URL:
https://script.google.com/macros/s/AKfycbyoP8c3_wlons5PSHx1W8PWJx4pn7t3ch-_IxTz0dVIKFw1AGLN/exec
12. Add jQuery library
In Articulate, add a trigger to run javascript (Execute Javascript) and use the code below.
This code will add the jQuery library to this project, so you won't have to change the HTML files after publishing the project. The jQuery library is needed for exporting the information to Google Drive.
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)
13. Store information
Add another trigger to run Javascript (Execute Javascript). You can use the code below.
Replace the value Current web app URL for the webapp url you've saved in step 11.
Below the webapp URL, you can place the column names of the spreadsheet and the Storyline variables. Please be aware of the comma if you add multiple variables.
var player = GetPlayer();
//PLACE YOUR WEB APP URL
WEB_APP_URL = "Current web app URL";
// 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
"name" : player.GetVar("name"),
"email" : player.GetVar("email"),
"message" : player.GetVar("message")
}
Don't delete the row below, if you would like to save the date when the form is sent:
"date" : new Date().toJSON().slice(0,10), //STORE DATE
14. Export code to Google Drive
Latest Javascript code. Add another trigger to run Javascript (Execute Javascript). You can use the code below. This trigger will send the information from step 13 to Google Drive.
//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);
15. Publish to SCORM or WEB format
Publish your articulate project to WEB or SCORM format. You need to host it on a WEB server or somewhere like SCORM cloud (or a LMS).
This export will work in Flash and HTML5 output. You can't use the Articulate Mobile Player, because it won't support Javascript code.
Thank You
Thanks Kate Robertson for making the blog post below:
Exporting Variables into a Google Spreadsheet
I started with your setup and then have tried to simplify the steps by changing the Javascript code and importing the JQuery Library.
- ELTCISSCommunity Member
Thank you for this awesome tutorial. This is something that will give us loads of great new options for how we use Storyline. In many cases having student responses export to a Google Sheet will be so much more accessible and versatile than having them export to the LMS. Example: we can then use FormMule to process the data, e.g. to email students a copy of the answers with feedback.
It took a while to understand why it wasn't working. Because of the changes Google has made, the location of the Run, Run function, setup has changed in the script editor, so I was running it with the doGet setting selected. You now have to click the drop down that is initially set to doGet and change it to setup, then click Run. Thank you @Vanessa Barnes for helping me to identify that mistake.
- LizzieAngellCommunity Member
Yay! you guys are awsome - got this working today :)
thanks for all the updates
- SherriSagers-caCommunity Member
Thanks for the updates on this!
- ChenBlum-411148Community Member
Hi everyone,
I'm using this code and it works fine.
Is thקre away to update rows that are already filled on the googlesheet?
I made an onboarding non linear program and I'm trying to understand my users behavior I want to know if they got to all my chaters on my storyline, did they go in more than once and which chapter is mose effective.
So I have a varible for each chapter and a counter on the entrance for each chapter
at the exit I'm using this code.
But if my user got out and after a while got back in I'm geting a new row. So I'm using pivot table to sum all data for the same user using User mobile no. as ID.
Is there a way to update original rows on the googlesheet? - JeremyLippartCommunity Member
I've only been using Storyline for a few weeks but this ability to export user data directly to google sheets would solve alot of issues for us. Unfortunately I cannot for the live of me get this to work. I've followed all of the steps and read through all the questions and follow up replies. I've even tried editing some of the storys people have uploaded and linked them to my Googlesheet/web app.
I've enclosed the very basic story I've created and pasted a link to the spreadsheet
I've tried adjusting the order of when javascript would execute etc. but have had no luck. Any help would be greatly appreciated
- aaronkapala-97bCommunity Member
Hi Jeremy,
I've just had a look and I moved the initial Javascript trigger from the first slide to the main slide where you are submitting the results. I've published it and tested via ScormCloud and it's updated on your spreadsheet.
Best wishes,
Aaron
- JeremyLippartCommunity Member
Thanks! I knew it was something simple that I wasn't quite seeing. I appreciate it
- PaulLavilleCommunity Member
Hi,
This looks like the solution I need, however I can't get past first base as the 'script editor' function in 'Tools' (on Google Sheets) no longer seems to be available.
Since this solution was first posted 7 years ago, is there an updated version which can help guide me towards populating a Google sheet with data from Storyline 360?
Any help would be much appreciated :)
Paul
- SteveFlowersCommunity Member
It's under Extensions > Apps Script now.
- SteveFlowersCommunity Member
I've switched away from using a web app endpoint in Google Apps script to using a Google Form as the endpoint. Easier to test and arguably simpler.
- PaulLavilleCommunity Member
Aha! Thanks Steve!
Google forms sounds interesting. Is the process similar?
- JonEzell-a06257Community Member
Thanks for the excellent tutorial. Unfortunately it looks like Google is now requiring payment to allow people to develop Apps with automated functionality. The current price for a single app is $50 a month. Maybe Articulate could, like, I don't know, build a product that has this functionality. I know it's a crazy idea, right? An Articulate product that actually reports data back to you or to an LMS? Not just a quiz results slide that requires you use the k12 fingerpaint default design settings for 3-5 multiple choice questions BUT ACTUAL, ROBUST DATA?! That's too much to ask for the paltry $600 per year per user that we pay. We've been embedding Qualtrics Survey forms into Storyline but that doesn't allow you to capture anything besides what is on a single slide in the deck. Yes, you can use query string logic to pass one or two simple variables along, but that doesn't really give you much information. Storyline is going to become an irrelevant knock off of Powerpoint 2016 if Articulate can't figure some sort of solution to this out. The frustrating thing is that I KNOW they can, they just don't. It's just like with accessibility ... you get these cheerful responses from staff but never any progress is made. Y'all kinda had an excuse when Adobe killed off Flash and you had to rebuild Storyline. But that was like 5 years ago. Adobe won't be terrible in this space forever Articulate. Make it work.
- PaulLavilleCommunity Member
Hi Jon
Google has changed its dashboard a bit in the years since this post went up, but you can create the script for free (at least as of today). Go into EXTENSIONS/ APPS SCRIPT and pop your custom script in there.
Run it and deploy as per the above instructions.
May also be worth noting that we had to remove the "ENTER KEY" line from the script as that was causing issues.
Hope that helps :)