Hello everyone,
In the code for a page, I have integrated an iframe whose URL must include the query string from the host URL. Here is the code I am using:
{% set query_string = request.query|default("utm_source=site&utm_campaign=contact-entrant") %}
<span class="hidden debug">{{ query_string|pprint }}</span>
<iframe id="iframe-inscription" src="{{ 'https://app.test.com/inscription?mode=iframe&' ~ query_string }}" name="FACTO" scrolling="No" width="100%" style="border:none" height="750px" allowtransparency="true"></iframe>
When I look at the page preview (in a new window), the code works correctly and the host URL parameters are added to the iframe’s one. But once the page is live, the `query_string` variable is empty (she is well interpreted as String, but empty).
I can’t explain this type of behavior. Has anyone ever encountered a similar case?
Hi @SDEGLIAME,
Thank you for posting to the Community!
I’d like to tag in some of our Subject Experts to see if they have experienced this before -- Hi @colinwitt @Franci and @CHawkins Have any of you all seen this before? If so, how were you able to resolve? Any advice?
Cassie, Community Manager
Hi @SDEGLIAME, maybe a stupid question but since you are just checking the query parameters of the URL, did you make sure you are accessing the live page with queries?
Because the preview always has a query (something like ?hsPreview=…) but a live page doesn’t necesarily need to have queries.
So if the page is something like mywebsite.com and has no queries, then it makes sense that you code is not working.
Maybe it’s worth adding some logic for when that happens and default to some specific and predefined queries so the iframe loads. But that’s up to you and your goals.
Do you maybe have a few links (with queries) we could use to test?