Hi everyone,
I am using a custom namespace in my (guided) landing page template. Is it somehow possible to leverage some of it in the landing page editor as well?
It seems like it's not even possible to do a
var td = {};
Is the editor filtering this out?
My goal would be to auto-fill a string template variable with the landing page URL and adding some UTM tags, which will then be used as the OG URL when sharing the page, so it's rendered with the page already.
Kind regards,
Thorsten
Solved! Go to Solution.
Oh wait, you mean setting the value of an input in the parent window (the LP Editor) using JS on the page itself. Certainly possible — or used to be when I wrote something similar to hook up a color picker in the editor.
Are you asking if you can include a local <script> element in an editable content area using the HTML source editor? Not sure what this has to do with namespaces — do you mean namespaced HTML elements? Please provide more info here.
Ok, maybe I shouldn't have gotten hung up on the word "namespace".
To clarify what I am trying to do:
It's starting to dawn on me that I need to dig a level deeper into the window of the iFrame.
What IFRAME? It sounds like there’s a lot you’re not mentioning here!
Oh wait, you mean setting the value of an input in the parent window (the LP Editor) using JS on the page itself. Certainly possible — or used to be when I wrote something similar to hook up a color picker in the editor.
Exactly! Thanks for wording it properly, Sanford 😀
Well, I got as far as solving my initial problem with a simple
if (/.marketodesigner.com$/.test(document.location.hostname)) {
parent.td = td;
}
only to then get into a CORS issue... I'll drop the plan here, it's becoming way to much effort for a little nifty nice-to-have convenience.
@SanfordWhiteman & all, if anyone of you like a challenge - give it a try! 😁 The goal would be the set the template variable ("the value of an input in the parent window") with the URL of the landing page and populate the OG meta tag for the URL like:
<!-- MARKETO VARIABLES -->
...
<meta class="mktoString" mktoName="[OG] Url" id="og_url" default="https://example.com/" />
...
<!-- OG Meta Tags -->
...
<meta property="og:url" content="${og_url}" />
...
So one could also set some default UTMs on that OG URL like
?utm_source=marketo&utm_medium=pageshare&utm_id=the+program+name
in one go and save some manual work for the marketing staff.
As always, thanks for your help - even if this goes nowhere, I have learned a lot trying 😂
Isn’t there a more immediate problem that the URL of the approved LP isn’t readable from the child IFRAME nor from the parent? Have you found that value?
Well, this code on StackOverflow I used to search the Window object says it is somewhere deep deep down in
Ext4.ClassManager.classes["Ext.ComponentMgr"].all.map["tbtext-1030"].ownerCt.ownerCt.items.map["lpEditor-1034"].items.map["lpEditorPredefinedLayout-1035"].items.map["lpPredefinedLayoutCanvas"].landingPage.raw.properties.destinationUrl
But i don't know how reliable or solid that is. So far, on different templates I tested in different instances (sandbox/production), it seems rock solid.
Before that I used the input with name=lpurl, which only exists when a form is present. But I was going to address that issue later...
Years ago I saw something like this put into a client instance and it was a real headache to work with the page in the editor. It did something a little differently and re-arranged the order of the Variables panel but used a similar approach. I hated working with the pages that were setup this way and we ended up remaking a new template that didn't have all the "jazz" in there. All-in-all it made for a bit of an improvement to the User Experience but it came at a significant tradeoff with intermittent load lag and weird "in-between" states that really made the UX worse than unorganized (and stable) fields in the Variables panel.
I'd say something like this is pretty cool, and maybe a fun rabbit hole to run along but probably not worth it in the long run (yet). I think it'd be inviting stability issues until Marketo opens something like that up natively and might end up being more maintenance than you bargained for compared to just manually setting a color or URL variable value. If you're looking for job security tho, it might be a good way to ensure that you're busy in the future 😉