Forum Discussion
Exporting Variables into a Google Spreadsheet
Heya Kate -
I've used the method you show here as well and it works pretty well to setup a Google Spreadsheet as an endpoint. This method is handy for capturing inline survey results, to grab choices for choice analysis, and for double capturing completions if your LMS happens to be temperamental. One of the cool things about the Google Spreadsheet is the notification / subscription feature. Subscribing to updates on a per-addition or digest basis is great for infrequent submissions. It's also handy to use formulas and linked sheets to create public dashboards. The original data can be locked away while the linked data (filtered and sanitized) can be exposed in a published location.
Here's an alternate method that uses a Google Form as the intermediary to submit the fields from Storyline. A little less setup using a form to process the submissions and I've had fewer issues with permissions (if your Google Apps instance is corporate or government, using GAPPS script is potentially problematic).
Add this to a trigger when the slide loads. This will write the JQuery library to your header so you won't need to do any post-publish surgery. This will load Jquery for both the HTML and HTML5 versions. This can also be used for other libraries. I've successfully used this method to load up the soundmanager.js library for persistent background music.
function add_script(scriptURL,oID) {
var scriptEl = document.createElement("script");
var head=document.getElementsByTagName('head')[0];
scriptEl.type = "text/javascript";
scriptEl.src = scriptURL;
scriptEl.id=oID;
head.appendChild(scriptEl);}
//only want to add these once!
if(document.getElementById('jquery')==null){
add_script("https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js","jquery");
}
After you've built your form and viewed the live form, inspect the form elements or explore the source to find the field references for your form. These will be something like entry.156531987. Write these down or copy them into another reference document. While you're at it, grab the form ID from the URL.
var player=GetPlayer();
var vRate=player.GetVar("slider1");
var vSuggestion=player.GetVar("TextEntry");
var fTarget="https://docs.google.com/a/nara.gov/forms/d/YOURFORMID/formResponse";
function submit_form(){$.ajax({
url: fTarget,
type: "POST",
data: {"entry.156531987" :vRate,"entry.1547132205":vSuggestion},
success: function(data) {
//won't return anything since it's cross domain
}
});
return false;
}
setTimeout(submit_form(), 2000);
Edit: Left off a little bit. I delay the submission of data for a couple of seconds for some reason. Must have fixed an issue in testing. Probably will work find without the delay.
Thanks Steve!
Bonnie