SOLVED

URL Parameter on Non-Marketo Landing Pages

Go to solution
Jenn_DiMaria2
Level 10

URL Parameter on Non-Marketo Landing Pages

We are placing Marketo forms on non-Marketo landing pages using the form HTML (not as an iframe).  Will we need to add javascript to our pages to capture the URL Parameters, or can we leave the form set-up as-is and the Marketo code will handle the rest?
Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Re: URL Parameter on Non-Marketo Landing Pages

Hi Jenn, you will need to add some script to you page to capture the URL parameters since your form is on a non-Marketo landing page. The native URL parameter functionality only works if the form is on a Marketo landing page.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Re: URL Parameter on Non-Marketo Landing Pages

Hi Jenn, you will need to add some script to you page to capture the URL parameters since your form is on a non-Marketo landing page. The native URL parameter functionality only works if the form is on a Marketo landing page.
Jenn_DiMaria2
Level 10

Re: URL Parameter on Non-Marketo Landing Pages

Hi Kate!  That's what I thought, but was hoping it wasn't true 🙂  Okay, now I know my plan of action.  Thanks!
Anonymous
Not applicable

Re: URL Parameter on Non-Marketo Landing Pages

I used this script before the closing </body> tag in the page HTML:

<script type="text/javascript">
 
function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}
    var cmp = getUrlVars()["cmp"];
 
    if  (cmp != null) {
    $("input#MKTOCampaign").val(cmp);
    }
 
</script>

The name of the field I wanted to pull a value into was MKTOCampaign and the name of our parameter was cmp, so you would want to replace that text with your field ID and URL parameter. I hard-coded the default value into the #MKTOCampaign field on the form HTML that I exported like so:

<input class='mktFormHidden' name="MKTOCampaign" id="MKTOCampaign" type='hidden' value="701E0000000ADt2" />

The script above runs when the page is loaded, and checks to see if there is a cmp parameter in the URL. If there is, it updates the MKTOCampaign field with the new campaign ID from the URL. If there isn't, it keeps the default value that I had initially hard-coded. It worked pretty well!