Redirect to Thank You page and append query variables to the URL

Highlighted
Level 10 - Community Moderator

Re: Redirect to Thank You page and append query variables to the URL

You have to be a user of a Marketo instance to view the Community.

Highlighted

Re: Redirect to Thank You page and append query variables to the URL

So my question is I have one post in that i'm mentioning some campaign names. Using these campaign names, in marketo form settings page i have placed some download links.EX: If the campaign name is A download a.pdf like this i have placed in form settings page. And i'm displaying custom message on the same post page.

Now I have created a thank you page. In that one download button is there if a user click on that button the above mentioned procedure need to happen. 

Highlighted
Level 10 - Community Moderator

Re: Redirect to Thank You page and append query variables to the URL

Using these campaign names, in marketo form settings page i have placed some download links.

Is "campaign name" just a custom (String) field that you happen to call "campaign name"?  It's confusing when you don't distinguish this from the actual Marketo Smart Campaign name, i.e. the {{campaign.name}} token.

And when you say "download links" I think you actually mean Thank You Pages, since Form Editor has no such setting as a "download link".  To be sure, you might have chosen to have a download button on your Thank You Page, but that's not something the Form Editor knows about/cares about.

Can you please clarify the above, using Marketo-specific terminology?


Are you asking how to redirect someone to a fixed URL (let's say /get-your-download.html) and also pass the URL of a downloadable file in its query string, so that a button on /get-your-download.html can be modified on-the-fly to point to the downloadable file?

Highlighted

Re: Redirect to Thank You page and append query variables to the URL

Are you asking how to redirect someone to a fixed URL (let's say /get-your-download.html) and also pass the URL of a downloadable file in its query string, so that a button on /get-your-download.html can be modified on-the-fly to point to the downloadable file? ------  YES 

Highlighted
Level 10 - Community Moderator

Re: Redirect to Thank You page and append query variables to the URL

Are you asking how to redirect someone to a fixed URL (let's say /get-your-download.html) and also pass the URL of a downloadable file in its query string, so that a button on /get-your-download.html can be modified on-the-fly to point to the downloadable file? ------  YES 

OK, at last we have a specification.

So on the form page, you use code similar to the above to add the downloadable URL (the Thank You Page in Form Editor)  as the #hash of the global download page:

MktoForms2.whenReady(function(form) {
form.onSuccess(function(vals, tyURL) {
var rewrittenTYLoc = document.createElement("a");

rewrittenTYLoc.href = "https://pages.example.com/get-your-download-html";
rewrittenTYLoc.search = tyURL.search;
rewrittenTYLoc.hash = encodeURIComponent(tyURL);
document.location = rewrittenTyLoc;

return false;
});
});‍‍‍‍‍‍‍‍‍‍‍‍

On /get-your-download.html, assuming you have an identifiable <a> tag (perhaps styled as a button) like this:

<a id="get-download" href="">Get your download here</a>

Then in your <head> on /get-your-download.html put the code:

document.addEventListener("DOMContentLoaded", function(e){
document.querySelector("#get-download").href = decodeURIComponent(document.location.hash.substring(1));
});‍‍‍
Highlighted

Re: Redirect to Thank You page and append query variables to the URL

Thank you so much for the help. This worked form me and one last question,
As I mentioned based on campaign name we are placing one link in the choice section, how to store these campaign names from wordpress dashboard to marketo form on submit.

For suppose consider a page with form in the page, in that page I have a campaign name called X. On form submit from that page, I want to updated that X campaign name in marketo. 

Highlighted
Level 10 - Community Moderator

Re: Redirect to Thank You page and append query variables to the URL

Thank you so much for the help. This worked form me...

Great, can you mark my answer (the recent one with the code) as Correct?

... and one last question,

As I mentioned based on campaign name we are placing one link in the choice section, how to store these campaign names from wordpress dashboard to marketo form on submit.

For suppose consider a page with form in the page, in that page I have a campaign name called X. On form submit from that page, I want to updated that X campaign name in marketo. 

That's actually 2 questions.

First is easy, if the campaign name is a Wordpress page-level variable or suchlike, output it into JavaScript, then call form.addHiddenFields to add it to the form.

Second is not possible. You can't use a form field value (e.g. database field value) in a flow step that expects a Smart Campaign, even if the value exactly matches a Marketo Campaign Name. (Actually, it's the numeric Campaign ID that's stored, not the Campaign Name, but that doesn't work either.) You have to build options using Add Choice and hard-code each possible value.

Highlighted

Re: Redirect to Thank You page and append query variables to the URL

Need to do first option can you help me in doing that.

Highlighted
Level 10 - Community Moderator

Re: Redirect to Thank You page and append query variables to the URL

You'll have to get it into JS first (like into a global JS variable), then I can show you how to add it as a form field.

Highlighted

Re: Redirect to Thank You page and append query variables to the URL

Hi Sanford Whiteman‌  the download link is not working don't know why. its just showing the page URL ln the download button instead of pdf link.