Hello Wix Velo community!
Hi everyone!
After 211+ failed attempts
, I’m reaching out to the community for help. We have a specific issue: Page Code captures UTM parameters and stores them in sessionStorage, but the iframe cannot retrieve these values - resulting in empty fields in the webhook and lost campaign data.
CONTEXT & BACKGROUND
✓ Tested the official Wix example: https://www.wix.com/velo-examples/hello-strg-studio
→ Works in Wix Studio editor preview mode
→ FAILS when customizing and using our custom iframe✓ No masterpage.js in our project (isolated issue)
✓ Page Code imports:
import { session } from ‘wix-storage’;
import wixLocation from ‘wix-location’;
import wixData from ‘wix-data’;
import { local } from ‘wix-storage’;
✓ Read extensively in community posts:
- How to redirect - #5 by nickolaeva
- localStorage not working between pages
- Local storage variable values not passing from one page to next
- localStorage.getItem returns null
THE REAL ISSUE
Page Code successfully stores UTM params in sessionStorage, BUT the iframe HTML component cannot read these stored values when trying to retrieve them. Result: all UTM params show as null/empty in the webhook.
The issue isn’t sending data TO the iframe it’s that the iframe cannot ACCESS wix-storage (session/local) from browser context.
STEPS WE FOLLOWED
STEP 1: Page Code captures and stores UTM
(This part WORKS ✓)
import { session } from ‘wix-storage’;
import wixLocation from ‘wix-location’;
w.onReady(async function() {
try {
// Capture full URL with UTM params
const urlCompleta = wixLocation.url;
// Extract UTM parameters
const queryObj = wixLocation.query;
const utmParams = {
utmsource: queryObj.utmsource || null,
utmmedium: queryObj.utmmedium || null,
utmcampaign: queryObj.utmcampaign || null,
utmcontent: queryObj.utmcontent || null,
utmterm: queryObj.utmterm || null,
gclid: queryObj.gclid || null,
// ... other UTM parameters
};
// STORE in sessionStorage
await session.setItem('wixutmparams', JSON.stringify(utmParams));
console.log('✓ UTM stored in session:', utmParams);
} catch (err) {
console.error(‘Error capturing UTM:’, err);
}
});
✓ **Console shows:**
V210-PAGE UTM stored in session: { utmsource: “google”, utmmedium: “paid”, … }
**STEP 2: iframe tries to READ from sessionStorage**
(This part FAILS ✗)
✗ **Console shows:**
Uncaught ReferenceError: session is not defined
localStorage.getItem(‘wixutmparams’) returns: null
THE PROBLEM - DETAILED
- Page Code context (worker) = has access to `wix-storage` (session/local)
- iframe context (browser) = NO access to `wix-storage`
- iframe cannot import `wix-storage`
- iframe cannot call `session.getItem()` or `local.getItem()`
- iframe CAN use native `localStorage`/`sessionStorage`, BUT Wix keeps it isolated
- Result: Data stored by Page Code in Wix’s session storage is NOT readable from iframe
This seems like a Wix sandbox security boundary that blocks cross-context storage access.
QUESTIONS FOR THE COMMUNITY
-
Is there a documented way to pass data from Page Code to iframe through wix-storage?
- Besides postMessage (which we’ve tried listener doesn’t work in Page Code worker context)
-
Does Wix sandbox intentionally isolate iframe from wix-storage?
- If so, is there an alternative architectural approach?
-
Has anyone successfully transferred UTM data from Page Code → iframe in production?
- What method did you use?
-
Is postMessage the ONLY option?
- We need the iframe to receive data that Page Code captures before the iframe loads
EXPECTED FLOW (That should work but doesn’t)
URL loaded: ?utm_source=google&utm_medium=paid&utm_campaign=test-v210
↓
Page Code (worker) executes:
→ Captures URL via wixLocation.url ✓
→ Extracts UTM via wixLocation.query ✓
→ Stores in session.setItem(‘wixutmparams’, {…}) ✓
→ Logs “UTM stored in session” ✓
↓
iframe HTML loads:
→ Tries: session.getItem(‘wixutmparams’) ✗ FAILS
→ Tries: localStorage.getItem(‘wixutmparams’) ✗ Returns NULL
→ Cannot read data = form remains empty
→ Webhook sent with: utmsource: null (LOST!)
↓
Expected result: utmsource: “google” in webhook
Actual result: utmsource: null in webhook
ENVIRONMENT INFO
- Wix Velo: Enabled
- Page Code: Active on page
- iframe: HTML Component embedded in Wix
- Storage tested: wix-storage (session), localStorage, memory
- Browser: Chrome Latest (tested)
- Wix Mode: Domain test (teste.wixstudio.com/”site”)
## WHAT WE NEED
A working example OR clarification on:
- ✓ How to reliably pass UTM data from Page Code to iframe
- ✓ Whether wix-storage is accessible from iframe context
- ✓ Alternative methods if postMessage listener doesn’t work in Page Code worker
Any dev who has solved this: please share your approach!
Thank you for your help!
TAGS:
wix-data wix-urls-v2 urls wix-storage-frontend site-storage wix-studio