Learning Systems & Architecture
How to Communicate Between Storyline and Web Objects Using Variables
Learn how to communicate between Storyline and web objects using JavaScript variables. This step-by-step tutorial covers reading learner data, sending scores back to your course, and building interactive embedded content with complete working code examples.
By Nathan Stoker · Published May 3, 2026 · 14 min read

Want your web objects to talk to Articulate Storyline? You can pass data back and forth between your course and embedded HTML content using JavaScript and Storyline variables. This opens up possibilities for custom interactions, external tools, and dynamic content that responds to learner progress.
In this tutorial, you'll learn how to communicate between Storyline and web objects using the player API. We'll cover sending data from Storyline to your web object, receiving data back from your web object, and building a complete working example you can adapt for your own projects.
Why Connect Web Objects to Storyline Variables?
Web objects let you embed HTML content directly into your Storyline slides. But static embedded content only gets you so far. The real power comes when your web object can read and write Storyline variables.
With variable communication, your web objects can:
Display personalized content based on the learner's name or progress
Send quiz scores or interaction data back to Storyline
Track time spent or actions taken within the embedded content
Unlock course navigation based on web object completion
Sync state between multiple web objects across slides
The connection happens through Storyline's JavaScript API, which your web object can access because it runs in the same browser context as your published course.
Understanding the Player API
Storyline exposes a JavaScript object called GetPlayer() that provides access to course variables. Your web object calls this function to get a reference to the player, then uses two methods to read and write variables.
The two essential methods are:
GetVar("variableName")– Reads the current value of a Storyline variableSetVar("variableName", value)– Updates a Storyline variable with a new value
These methods work with all Storyline variable types: text, number, and true/false. The variable must already exist in your Storyline project before your web object can access it.
Setting Up Your Storyline Project
Before creating your web object, set up the variables you'll use for communication. This establishes the "contract" between Storyline and your embedded content.
Step 1: Create Your Variables
Open your Storyline project and access the Variables panel by clicking the Variables button in the Triggers panel or pressing Ctrl+Shift+V.
Create the variables your web object will read or write. For this tutorial, create these three variables:
Variable Name | Type | Default Value | Purpose |
|---|---|---|---|
learnerName | Text | (empty) | Passed to web object |
webObjectScore | Number | 0 | Received from web object |
webObjectComplete | True/False | False | Received from web object |
Use descriptive names that clearly indicate the variable's purpose. This makes your project easier to maintain and debug.
Step 2: Insert Your Web Object
Navigate to the slide where you want your web object to appear. Go to Insert > Web Object and choose how to load your content:
File – Browse to a local HTML file in your project folder
Address – Enter a URL to load external content
For this tutorial, we'll create a local HTML file. Select "File" and we'll create the HTML content in the next section.
Step 3: Configure Web Object Settings
After inserting the web object, double-click it to access settings:
Display – Choose "Display in slide" to embed the content
Load web object – Select "Automatically" to load when the slide timeline starts
Browser Settings – Leave default unless you need specific features
Position and resize the web object on your slide. The embedded content will scale to fit this container.
Creating Your Web Object HTML File
Now let's build the HTML file that will communicate with Storyline. This file lives in your project folder and gets published alongside your course.
Basic HTML Structure
Create a new file called communication-demo.html with this starter template:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Storyline Web Object</title>
<style>
/* Styles will go here */
</style>
</head>
<body>
<!-- Content will go here -->
<script>
// JavaScript will go here
</script>
</body>
</html>
Save this file in your Storyline project folder or a subfolder you can easily reference.
Reading Variables from Storyline
To read a Storyline variable from your web object, use GetPlayer().GetVar(). The key consideration is timing—you need to ensure Storyline's player is available before your code runs.
Accessing the Parent Window
Your web object runs inside an iframe. Storyline's player lives in the parent window. To access it, you reference parent.GetPlayer() instead of just GetPlayer().
Here's the pattern for safely reading a variable:
// Get reference to Storyline's player in the parent window
var player = parent.GetPlayer();
// Read a variable value
var learnerName = player.GetVar("learnerName");
// Use the value in your web object
document.getElementById("greeting").textContent = "Hello, " + learnerName + "!";
Handling Missing Values
Always check for empty or undefined values before using them. Storyline text variables default to empty strings, which can cause display issues:
var player = parent.GetPlayer();
var learnerName = player.GetVar("learnerName");
// Provide a fallback for empty values
if (learnerName && learnerName.trim() !== "") {
document.getElementById("greeting").textContent = "Hello, " + learnerName + "!";
} else {
document.getElementById("greeting").textContent = "Hello, Learner!";
}
Writing Variables to Storyline
Sending data back to Storyline works similarly. Use SetVar() with the variable name and the new value. Storyline will update the variable immediately, and any triggers watching that variable will fire.
Basic Variable Writing
var player = parent.GetPlayer();
// Write a number value
player.SetVar("webObjectScore", 85);
// Write a text value
player.SetVar("feedbackText", "Great job completing the activity!");
// Write a true/false value
player.SetVar("webObjectComplete", true);
Triggering Storyline Actions
This is where the magic happens. When your web object updates a Storyline variable, you can have triggers respond to that change. For example:
In Storyline, create a trigger:
Action: Show layer
Layer: Completion Message
When: Variable changes
Variable: webObjectComplete
Condition: If webObjectComplete is equal to True
Now when your web object sets webObjectComplete to true, Storyline automatically shows the completion layer. Your embedded content directly controls the course flow.
Complete Working Example
Let's put everything together with a complete, working example. This web object displays a personalized greeting, presents a simple interaction, and sends results back to Storyline.
Complete HTML File
Save this as storyline-communicator.html in your project folder:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Storyline Communication Demo</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.container {
background: white;
border-radius: 16px;
padding: 30px;
max-width: 450px;
width: 100%;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.greeting {
font-size: 1.5em;
color: #1e3c72;
margin-bottom: 20px;
text-align: center;
}
.instruction {
color: #666;
margin-bottom: 25px;
text-align: center;
line-height: 1.5;
}
.question {
background: #f8f9fa;
border-radius: 12px;
padding: 20px;
margin-bottom: 20px;
}
.question-text {
font-weight: 600;
color: #333;
margin-bottom: 15px;
}
.options {
display: flex;
flex-direction: column;
gap: 10px;
}
.option-btn {
padding: 12px 20px;
border: 2px solid #e0e0e0;
border-radius: 8px;
background: white;
cursor: pointer;
font-size: 1em;
text-align: left;
transition: all 0.2s ease;
}
.option-btn:hover {
border-color: #2a5298;
background: #f0f4ff;
}
.option-btn:focus {
outline: none;
border-color: #2a5298;
box-shadow: 0 0 0 3px rgba(42, 82, 152, 0.2);
}
.option-btn.correct {
border-color: #28a745;
background: #d4edda;
color: #155724;
}
.option-btn.incorrect {
border-color: #dc3545;
background: #f8d7da;
color: #721c24;
}
.option-btn:disabled {
cursor: not-allowed;
opacity: 0.7;
}
.feedback {
padding: 15px;
border-radius: 8px;
margin-top: 20px;
display: none;
}
.feedback.show {
display: block;
}
.feedback.correct {
background: #d4edda;
color: #155724;
border: 1px solid #c3e6cb;
}
.feedback.incorrect {
background: #f8d7da;
color: #721c24;
border: 1px solid #f5c6cb;
}
.score-display {
text-align: center;
margin-top: 20px;
padding-top: 20px;
border-top: 1px solid #eee;
}
.score-label {
color: #666;
font-size: 0.9em;
}
.score-value {
font-size: 2em;
font-weight: bold;
color: #2a5298;
}
.status {
text-align: center;
margin-top: 15px;
font-size: 0.85em;
color: #888;
}
.status.connected {
color: #28a745;
}
.status.error {
color: #dc3545;
}
</style>
</head>
<body>
<div class="container">
<h1 class="greeting" id="greeting">Hello!</h1>
<p class="instruction">
Answer the question below. Your score will be sent back to Storyline.
</p>
<div class="question">
<p class="question-text">What does the GetPlayer() function return in Storyline?</p>
<div class="options" role="group" aria-label="Answer options">
<button class="option-btn" data-correct="false">
A. The current slide number
</button>
<button class="option-btn" data-correct="false">
B. The learner's name
</button>
<button class="option-btn" data-correct="true">
C. A reference to the Storyline player API
</button>
<button class="option-btn" data-correct="false">
D. The course completion status
</button>
</div>
</div>
<div class="feedback" id="feedback" role="alert"></div>
<div class="score-display">
<div class="score-label">Your Score</div>
<div class="score-value" id="scoreValue">0</div>
</div>
<div class="status" id="status">Connecting to Storyline...</div>
</div>
<script>
// Storyline Communication Demo
// This script demonstrates reading and writing Storyline variables
(function() {
// Store reference to Storyline player
var player = null;
var score = 0;
var answered = false;
// Initialize when page loads
document.addEventListener('DOMContentLoaded', init);
function init() {
// Attempt to connect to Storyline
connectToStoryline();
// Set up answer buttons
setupAnswerButtons();
}
function connectToStoryline() {
var statusEl = document.getElementById('status');
try {
// Access the parent window's GetPlayer function
player = parent.GetPlayer();
if (player) {
statusEl.textContent = 'Connected to Storyline';
statusEl.className = 'status connected';
// Read the learner's name from Storyline
readLearnerName();
} else {
throw new Error('Player not available');
}
} catch (e) {
// Running outside Storyline (for testing)
statusEl.textContent = 'Running in standalone mode (not connected to Storyline)';
statusEl.className = 'status error';
console.log('Storyline connection not available:', e.message);
}
}
function readLearnerName() {
// Read the learnerName variable from Storyline
var learnerName = player.GetVar('learnerName');
var greetingEl = document.getElementById('greeting');
// Display personalized greeting or default
if (learnerName && learnerName.trim() !== '') {
greetingEl.textContent = 'Hello, ' + learnerName + '!';
} else {
greetingEl.textContent = 'Hello, Learner!';
}
}
function setupAnswerButtons() {
var buttons = document.querySelectorAll('.option-btn');
buttons.forEach(function(button) {
button.addEventListener('click', function() {
if (answered) return; // Prevent multiple answers
handleAnswer(this);
});
// Keyboard accessibility
button.addEventListener('keydown', function(e) {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
if (!answered) {
handleAnswer(this);
}
}
});
});
}
function handleAnswer(selectedButton) {
answered = true;
var isCorrect = selectedButton.getAttribute('data-correct') === 'true';
var feedbackEl = document.getElementById('feedback');
var buttons = document.querySelectorAll('.option-btn');
// Disable all buttons
buttons.forEach(function(btn) {
btn.disabled = true;
});
// Show correct/incorrect styling
if (isCorrect) {
selectedButton.classList.add('correct');
feedbackEl.textContent = 'Correct! GetPlayer() returns a reference to the Storyline player API, which gives you access to variables and other course functions.';
feedbackEl.className = 'feedback correct show';
score = 100;
} else {
selectedButton.classList.add('incorrect');
// Highlight the correct answer
buttons.forEach(function(btn) {
if (btn.getAttribute('data-correct') === 'true') {
btn.classList.add('correct');
}
});
feedbackEl.textContent = 'Not quite. GetPlayer() returns a reference to the Storyline player API. This API lets you read and write variables using GetVar() and SetVar().';
feedbackEl.className = 'feedback incorrect show';
score = 0;
}
// Update score display
document.getElementById('scoreValue').textContent = score;
// Send data back to Storyline
sendDataToStoryline(score, isCorrect);
}
function sendDataToStoryline(score, completed) {
if (!player) {
console.log('Would send to Storyline - Score:', score, 'Complete:', completed);
return;
}
try {
// Write the score to Storyline
player.SetVar('webObjectScore', score);
// Mark the web object as complete
player.SetVar('webObjectComplete', true);
// Update status
var statusEl = document.getElementById('status');
statusEl.textContent = 'Score sent to Storyline successfully!';
console.log('Data sent to Storyline - Score:', score, 'Complete:', true);
} catch (e) {
console.error('Error sending data to Storyline:', e);
}
}
})();
</script>
</body>
</html>
How This Example Works
The code follows a clear flow:
On Load – The script attempts to connect to Storyline using
parent.GetPlayer()Read Variables – It reads
learnerNameand displays a personalized greetingUser Interaction – The learner answers a multiple-choice question
Write Variables – The script sends the score to
webObjectScoreand setswebObjectCompleteto true
The standalone mode detection lets you test the HTML file in a browser before publishing. The status message shows whether Storyline is connected.
Required Storyline Setup
For this example to work, your Storyline project needs:
Variables:
learnerName(Text) – Set this earlier in your course, perhaps from a data entry fieldwebObjectScore(Number) – The web object writes to thiswebObjectComplete(True/False) – The web object sets this to True when done
Optional Triggers:
Show a completion layer when
webObjectCompletebecomes TrueDisplay the score using a text reference:
%webObjectScore%Enable the Next button when
webObjectCompleteequals True
Troubleshooting Common Issues
When your web object isn't communicating properly, check these common issues.
"GetPlayer is not defined" Error
This usually means your code is running before Storyline's player is available. Wrap your code in a DOMContentLoaded event listener and access the player through the parent window:
document.addEventListener('DOMContentLoaded', function() {
var player = parent.GetPlayer();
// Your code here
});
Variables Not Updating
Verify that:
The variable exists in Storyline with the exact spelling (case-sensitive)
You're using the correct variable type (text, number, or true/false)
The web object has finished loading before accessing variables
Cross-Origin Restrictions
If you're loading content from an external URL, browser security may block communication. Local HTML files published with your course don't have this issue. For external content, ensure both domains allow the necessary access.
Testing Outside Storyline
Your web object won't connect to Storyline when opened directly in a browser. Add error handling to detect this and provide fallback behavior:
try {
var player = parent.GetPlayer();
if (!player) throw new Error('No player');
// Connected to Storyline
} catch (e) {
// Running standalone - use test data
console.log('Standalone mode');
}
Best Practices for Variable Communication
Follow these guidelines for reliable web object communication.
Use Clear Naming Conventions
Prefix variables used for web object communication so they're easy to identify:
wo_scoreinstead ofscorewo_completeinstead ofcompletewo_userInputinstead ofuserInput
Validate Before Writing
Check that values are valid before sending them to Storyline:
function sendScore(value) {
// Ensure it's a number
var score = parseInt(value, 10);
if (isNaN(score)) score = 0;
// Clamp to valid range
score = Math.max(0, Math.min(100, score));
player.SetVar('webObjectScore', score);
}
Provide Feedback
Let learners know when data has been saved. A brief confirmation message prevents confusion about whether their progress was recorded.
Handle Connection Failures Gracefully
Not all environments support the player API. Design your web object to function (even with limited features) when Storyline isn't available.
Conclusion
Learning to communicate between Storyline and web objects using variables transforms static embedded content into dynamic, interactive experiences. You can personalize content with learner data, capture interaction results, and control course flow based on web object completion.
The key concepts to remember: use parent.GetPlayer() to access Storyline from your web object, GetVar() to read variables, and SetVar() to write them. Create your variables in Storyline first, then reference them by exact name in your JavaScript.
Start with the complete example in this tutorial, then adapt it for your own custom interactions. Once you're comfortable with basic variable passing, you can build sophisticated integrations that make your courses truly interactive.
Nathan Stoker
I build custom eLearning in Storyline, Rise and JavaScript, and I make the free tools and templates on this site. Need an interaction like this in your course? Let's talk.