# UTM Parameters from Wix Velo Page Code to iframe – Works in Studio Preview but Fails on Customization

**URL:** <https://forum.wixstudio.com/t/utm-parameters-from-wix-velo-page-code-to-iframe-works-in-studio-preview-but-fails-on-customization/75106>\
**Category:** Ask the community\
**Tags:** wix-location-frontend, wix-data, code, wix-blocks\
**Created:** [November 20, 2025, 4:20pm UTC](https://forum.wixstudio.com/t/utm-parameters-from-wix-velo-page-code-to-iframe-works-in-studio-preview-but-fails-on-customization/75106 "2025-11-20T16:20:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![suporteordercompany](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/suporteordercompany/32/89267_2.png) [@suporteordercompany](https://forum.wixstudio.com/u/suporteordercompany)\
**Post date:** [November 20, 2025, 4:20pm UTC](https://forum.wixstudio.com/t/utm-parameters-from-wix-velo-page-code-to-iframe-works-in-studio-preview-but-fails-on-customization/75106/1 "2025-11-20T16:20:17Z")

</div>

**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](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](https://forum.wixstudio.com/t/how-to-redirect/26204/5)
- [localStorage not working between pages](https://forum.wixstudio.com/t/localstorage-not-working-between-pages/29476)
- [Local storage variable values not passing from one page to next](https://forum.wixstudio.com/t/local-storage-variable-values-not-passing-from-one-page-to-next/6789)
- [localStorage.getItem returns null](https://forum.wixstudio.com/t/localstorage-getitem-returns-null/53284)

## **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**

```javascript
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 ✗)

```

```javascript

✗ **Console shows:**

Uncaught ReferenceError: session is not defined
localStorage.getItem(‘wixutmparams’) returns: null

```

* * *

## **THE PROBLEM - DETAILED**

1. **Page Code context (worker)** = has access to **`wix-storage`** (session/local)
2. **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**

1. **Is there a documented way to pass data from Page Code to iframe through wix-storage?**

2. **Does Wix sandbox intentionally isolate iframe from wix-storage?**

3. **Has anyone successfully transferred UTM data from Page Code → iframe in production?**

4. **Is postMessage the ONLY option?**

## **EXPECTED FLOW (That should work but doesn’t)**

```javascript
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”](http://teste.wixstudio.com/%E2%80%9Dsite%E2%80%9D))

**## 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

---

<div class="post-metadata">

**Author:** ![noahlovell](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/noahlovell/32/118920_2.png) [@noahlovell](https://forum.wixstudio.com/u/noahlovell)\
**Post date:** [November 21, 2025, 11:23am UTC](https://forum.wixstudio.com/t/utm-parameters-from-wix-velo-page-code-to-iframe-works-in-studio-preview-but-fails-on-customization/75106/2 "2025-11-21T11:23:08Z")

</div>

I’d recommend using the `postMessage` approach to communicate between the iFrame and the page code.

We have a video that covers everything you’ll need to send data from the page to the iFrame, and then from the iFrame back to the page:

[![](https://us1.discourse-cdn.com/wix/original/3X/d/0/d00c3873a7d5644a9eb24cea526f5303b735c4b3.jpeg "How to Send Data between an iFrame and your Wix Site") ](https://www.youtube.com/watch?v=Nt8nw25hEr8&t=3s)

The video has always been my go to for remembering how to do this 🙂 Was there a specific need for using storage? Or was it just the first thought for sharing data between the page and iFrame?

---

<div class="post-metadata">

**Author:** ![suporteordercompany](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/suporteordercompany/32/89267_2.png) [@suporteordercompany](https://forum.wixstudio.com/u/suporteordercompany)\
**Post date:** [December 4, 2025, 8:27pm UTC](https://forum.wixstudio.com/t/utm-parameters-from-wix-velo-page-code-to-iframe-works-in-studio-preview-but-fails-on-customization/75106/3 "2025-12-04T20:27:11Z")

</div>

**Hi Wix Community Team,**

We want to say a genuine **thank you** for the documentation and support that  
made our **Page Code ↔ IFRAME** integration project successful.

**THE DOCS THAT SAVED US**

Three pieces of documentation were absolutely critical:

1. **wix-location API docs** - Showed us how to capture URLs with query params.
2. **iframe/introduction docs** - Explained postMessage as the solution.
3. **General examples in video** - Patterns of retry logic, error handling, config.

Without these, we would have:  
❌ Tried impossible approaches (accessing IFRAME DOM from Page Code)  
❌ Made security mistakes.  
❌ Spent weeks debugging timing issues.  
❌ Created unmaintainable code.

**Our project succeeded because we:**  
✓ Read your docs carefully.  
✓ Applied the principles.  
✓ Went deeper with our own experimentation.  
✓ Documented our findings.

**THANK YOU FOR:**  
✓ Building APIs that work.  
✓ Documenting them clearly.  
✓ Explaining the WHY.  
✓ Showing real examples.  
✓ Supporting developers.  
✓ Making Wix Velo approachable.

You’re making Wix Velo the most developer-friendly platform in the builder space.

Keep doing what you’re doing! 🙌

**With gratitude.**

**P.S. - If any developers need help with the code for the ↔ IFRAME page, I can add more details to this post. That’s what the Wix community is all about, helping each other.**

---

<div class="post-metadata">

**Author:** ![Adi\_Trudler](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/adi_trudler/32/112019_2.png) [@Adi\_Trudler](https://forum.wixstudio.com/u/Adi_Trudler)\
**Post date:** [December 18, 2025, 1:41pm UTC](https://forum.wixstudio.com/t/utm-parameters-from-wix-velo-page-code-to-iframe-works-in-studio-preview-but-fails-on-customization/75106/4 "2025-12-18T13:41:43Z")

</div>

This text is definitely not an Easter egg.

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/system/32/86885_2.png) [@system](https://forum.wixstudio.com/u/system)\
**Post date:** [January 17, 2026, 1:42pm UTC](https://forum.wixstudio.com/t/utm-parameters-from-wix-velo-page-code-to-iframe-works-in-studio-preview-but-fails-on-customization/75106/5 "2026-01-17T13:42:15Z")

</div>

Closed on January 17, 2026, 1:42pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
