Here's our scenario:
We create an interesting moment for a lead when they download a specific type of file from us. The name of that file is in the last part of the URL on the preceding page. Something like: www.southco.com//n-us/c5/c5-11-112 where we want to capture just the c5-11-112 portion of the URL. Right now we're defining the interesting moment by a trigger of clicking on a web page (the thank you page, essentially - but this all on our external website, not Marketo LPs) and giving the interesting moment the value of {{trigger.Referrer}}. This gets us the information about the file (part number) that we need to pass onto sales, but includes the extraneous URL data.
So, I want to rewrite the data in the interesting moment field by replacing the redundant parts of the URL with an empty space. I got partway there using a regular text token using JavaScript, but could not figure out how to pull the value of the token into the JS. My code looked something like this:
<script type="text/javascript">
var re = /http/gi;
var str = {{lead.Last Interesting Moment}};
var newstr = str.replace(re, "");
document.write(newstr );
</script>
I also tried:
<script type="text/javascript">
var re = /http/gi;
var str = "{{lead.Last Interesting Moment}}";
var newstr = str.replace(re, "");
document.write(newstr );
</script>
Neither of those worked, but if I replaced the token value with a static string like "Here is my URL http://www", it worked when placing that token on a landing page. (I saw "Here is my URL ://www".)
To try to get the value of the token, I thought I'd try the email script token method that's shown here:
https://community.marketo.com/MarketoArticle?id=kA050000000LB9MCAW
I am not a VLT developer by any means, so I was mostly just sort of trying things out in there. Here's what I tried:
${lead.LastInterestingMoment}
#set ($a = ${lead.LastInterestingMoment})
#set ($b = $a.replace("http://www.southco.com/", ""))
#set (${lead.LastInterestingMoment} = $b)
This did not strip out the "http://www.southco.com/" but did display the value of the {lead.LastInterestingMoment} token when I sent an email.
Is there a way to change the value of a field like this in Marketo? I'm not sure if I'm going about it the right way or using the right methods. Any feedback or experience is appreciated.
Thanks!