Re: Variables within an mktoText region for a Guided LP template

Anonymous
Not applicable

Variables within an mktoText region for a Guided LP template

I'm working on designing a Guided LP template. I have an editable region with social icons and the URLs for the social icons are variables.

The issue I'm running into is Marketo isn't properly rendering those variables. When I approve the LP and view the live URL the social icons are linked with this: ${TwitterURL}.

Anyone seen a way around this? I would prefer to keep the mktoText and the variable. this is because certain brands might need to update just the URL while some brands might need to remove an icon.

Thanks.

7 REPLIES 7
SanfordWhiteman
Level 10 - Community Moderator

Re: Variables within an mktoText region for a Guided LP template

There is, as we say, an "impedance mismatch" between variables and editable areas.

And in a theoretical way it makes sense, because a variable is expected to be used in a context where it can't be just deleted by the user, i.e. a fixed part of the page.  But in reality we sometimes want to use them as if they're tokens (and on the flipside, Marketo doesn't let us place enough restrictions on the use of tokens).

What we do is use the ${variable} as if it's a token and also include the ${variable} in a fixed JS block.

Something like this:

var urlVariables = {

  "TwitterURL" : "${TwitterURL}"

};

[].forEach.call(document.links,function(link){

  var lastPathSegment = link.pathname.split('/').pop(),

      lastPathSegDecoded = decodeURIComponent(lastPathSegment),

      mktoVariableRE = /^\$\{(.*)\}$/; // syntax like ${myvar}

  if ( mktoVariableRE.test(lastPathSegDecoded) ) {

    var variableName = lastPathSegDecoded.replace(mktoVariableRE,'$1');

    link.href = urlVariables[variableName];

  }

});

In a nutshell, replacing the token-like syntax "${TwitterURL}" with the variable's real value, whenever it's present in a link. The user is none the wiser about how the variable actually gets interpolated into the link, it just works.

Anonymous
Not applicable

Re: Variables within an mktoText region for a Guided LP template

Thanks for this suggestion!

I'm going to run this by our developers and give this a shot.

Thanks again!

-Kim

Grégoire_Miche2
Level 10

Re: Variables within an mktoText region for a Guided LP template

Hi Kim,

If you do not want to go by Sanford's JS approach, the other possibility is to avoid using variables and tokens here and make your element a mktoSnippet one.

The rationale behind using snippets here is that you can control who can create / edit / approve snippets. The other advantage is that, as for tokens and unlike variables, authorized users can also edit and approve snippets without having to reapprove all the landing pages using them.

-Greg

SanfordWhiteman
Level 10 - Community Moderator

Re: Variables within an mktoText region for a Guided LP template

But snippets don't really get you the same thing. Take the ability to switch a variable value (I've run into at the exact case of multiple Twitter @names) at LP level from a picklist or a textbox. If you use a snippet, that's still a problem.  (One assumes in this case there isn't a predictable connection between segments and Twitter accounts.)

Grégoire_Miche2
Level 10

Re: Variables within an mktoText region for a Guided LP template

Hi Sanford,

Yes, but most of the cases we have run into just create a few snippets to cover the different needs. Usually, we are talking about different social accounts for various BU's in the company, and these accounts will create 1 snippet for each BU, and be perfectly fine with it. This even better when running this in a multi-workspace environnement, because the template will be global (shared across workspaces) while the snippets will be local, so each local user will have the choice between 1 snippet , which significantly reduces the risk of errors.

-Greg

SanfordWhiteman
Level 10 - Community Moderator

Re: Variables within an mktoText region for a Guided LP template

Fair point for that case!

Anonymous
Not applicable

Re: Variables within an mktoText region for a Guided LP template

I didnt think about this! I don't think this is how we will approach this issue - but i can definitely see it being useful for other issues.

Thanks!

-Kim