I have a button that redirects a user from one dashboard to another. I need to pass some data between the first and second dashboard so I am adding it as a parameter to the URL. In the second dashboard it seems that I am unable to grab it. The parameter shows up in the URL like expected, but using window.location.search in the Custom HTML widget just returns an empty string so I can’t actually grab that parameter. I thought maybe creating a context variable with the same name/key in the second dashboard would work, but it doesn’t look like that is getting set either when the page loads. Is there any solution to this?
A Custom HTML Block renders within the context of its own <iframe />
, so the window
scope is not available within it. You can read more about that security feature here.
Instead, I would create a context variable for the value you want to pass through, and you can set that variable’s value through a query parameter (assuming you are doing this in an experience page).
I followed these steps, but it seems that I’m still running into issues. I added a context variable called storeNum to the experience page and set it equal to {{request.params.storeNum}}. I have a context variable in the dashboard as well with the same name and a default value of 5. I’m logging the ctx variables after the page loads, but it seems that the value is always stuck at 5 on the experience page. I’ve tried loading the page with both “?storeNum=10” and “?ctx[storeNum]=10”, but no dice. When I try it on the dashboard it works just fine however so I’m not exactly sure what’s different or what I’m doing wrong.
That should be {{request.query.storeNum}}
if you’re passing it as a query parameter.
At the top of the page editor you will see a “View Example Context” link. You may find that helpful when building this out.