SOLVED

One Global WordPress form for Resources Library

Go to solution
Jon-Sun_Lu1
Level 2

One Global WordPress form for Resources Library

I'm wondering if anybody has successfully implemented a single global WordPress form that customizes the download button URL to point to the individual PDF based on the page?

I'm trying to implement something similar to Marketo's own Resource library (i.e. Building Effective Landing Pages ), where a prospect can fill out one form for one resource, and never have to fill out the form again when they navigate to a new resource on the same site.

I've been using the "Form Embed" code, as well as using the "If Known HTML" to hide the form and show the Download button. My issue is how do I dynamically add the PDF URL to that button when I have 10 landing pages that use that same form?

I have a developer that is versed in javascript and jQuery but we're struggling with the best solution for achieving this. I'm open to any solutions or best practices that somebody has used before.

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: One Global WordPress form for Resources Library

I've been using the "Form Embed" code, as well as using the "If Known HTML" to hide the form and show the Download button. My issue is how do I dynamically add the PDF URL to that button when I have 10 landing pages that use that same form?

You dynamically set the Thank You URL using the Forms 2.0 API onSuccess listener. There are several ways to encode the TY URL in the LP, from metadata in the <head> to a JS variable to a URL parameter. Here I'll use the entire query string as the PDF URL.

MktoForms2.whenReady(function(form){

  form.onSuccess(function(vals,tyURL){

    document.location.href = document.location.search.substring(1);

    return false;

  });

});

View solution in original post

3 REPLIES 3
SanfordWhiteman
Level 10 - Community Moderator

Re: One Global WordPress form for Resources Library

I've been using the "Form Embed" code, as well as using the "If Known HTML" to hide the form and show the Download button. My issue is how do I dynamically add the PDF URL to that button when I have 10 landing pages that use that same form?

You dynamically set the Thank You URL using the Forms 2.0 API onSuccess listener. There are several ways to encode the TY URL in the LP, from metadata in the <head> to a JS variable to a URL parameter. Here I'll use the entire query string as the PDF URL.

MktoForms2.whenReady(function(form){

  form.onSuccess(function(vals,tyURL){

    document.location.href = document.location.search.substring(1);

    return false;

  });

});

Jon-Sun_Lu1
Level 2

Re: One Global WordPress form for Resources Library

Hi Sanford,

Awesome thanks so much, always appreciate your expertise on these boards, especially in terms of the more dev heavy quesitons.

I think we've got it working on the website

Take care!

SanfordWhiteman
Level 10 - Community Moderator

Re: One Global WordPress form for Resources Library

Cool!