You can trigger MediaOS Member Workflows directly from your website using a simple JavaScript snippet. This allows you to run a specific workflow for a logged-in user based on a page action, click, or load event—no form submission or manual input required.
When to Trigger Member Workflows via JavaScript #
This integration is helpful when you want to:
- Trigger an automated workflow based on user behavior (e.g., visiting a thank-you page, completing an action).
- Start a workflow without requiring form submission.
- Automate follow-ups, tagging, or audience changes for known logged-in members.
Note: This only works for workflows of the type Members and only triggers for logged-in users.
How It Works #
The following JavaScript loads the MediaOS script and calls a workflow once it’s loaded:
<script type="module" id="mosScript" src="https://mos-scripts.com/a/main.js"></script>
<script type="text/javascript">
document.getElementById('mosScript').addEventListener('load', function() {
window.mosWorkflow('INSERT_WORKFLOW_ID_HERE');
});
</script>
Replace INSERT_WORKFLOW_ID_HERE with your actual Workflow ID (this is the same as the Event ID listed in the Workflows > List tab inside MediaOS).
Tip: You can place this script inside a specific page (like a confirmation page or hidden landing page) to trigger the workflow automatically when the page loads.
Step-by-Step Guide #
- Go to Workflows in your MediaOS admin panel.
- Find the workflow you want to trigger and copy its Event ID.
- The workflow must be of type Members.
- Paste the following code snippet into your website page or script block.
- Replace INSERT_WORKFLOW_ID_HERE with your copied Event ID.
<script type="module" id="mosScript" src="https://mos-scripts.com/a/main.js"></script>
<script type="text/javascript">
document.getElementById('mosScript').addEventListener('load', function() {
window.mosWorkflow('abc123'); // Replace abc123 with your actual workflow ID
});
</script>
- Save and publish your page.
Warning: This only works for users who are logged in through MediaOS. If the visitor is not recognized, the workflow will not trigger.
Use Cases #
In some cases, you may want to trigger member workflows programmatically using JavaScript to create more dynamic, behavior-driven experiences. This approach is especially useful when user interactions occur outside the bounds of native platform automation—for example, on custom pages or third-party interfaces.
A common use case is initiating a welcome series after a new user completes registration and is redirected to a custom thank-you page. Similarly, you might enroll an already logged-in member into a re-engagement workflow after they interact with a specific call-to-action (CTA) within a marketing campaign. JavaScript-based triggers can also be employed to assign tags or add users to targeted audiences based on actions such as completing a gated download or meeting specific behavioral criteria.
By integrating workflow triggers into front-end logic, you gain granular control over how and when members are segmented, messaged, or guided through your lifecycle flows