Post field info to embedded form

Charles_Sander1
Level 4

Post field info to embedded form

I'm spending a little time on exploring Drupal 8 for our corporate website redesign. While doing this, I'm hoping to change how one of the Marketo forms gets its info.

Currently, when someone requests a white paper, we pass information in the URL string (Get)... Then the Marketo form can pull that information into a couple hidden fields. This has occasionally been problematic - and Google isn't indexing those pages with the passed variables. This leads to broken forms when people get there via Google.  (Plus, we're starting to use more UTM codes. This is making for one nasty-long URL.)

I'm hoping to completely circumvent this with the passed info, by achieving the same using Post, instead of Get. But I'd like some direction, solutions, how-to's, etc. Or, maybe somebody knows a simple solution. I know one likely short answer is "Use Javascript!" ...but I'm quite rusty in that area.

Thanks!

chs

6 REPLIES 6
Josh_Hill13
Level 10 - Champion Alumni

Re: Post field info to embedded form

Do you have more examples or a url? I feel like there's some missing piece here. Why are you doing it this way?

Charles_Sander1
Level 4

Re: Post field info to embedded form

Possibly.. wasn't sure what extra info was needed. Basically, the URL contains the resource title, and whether it's a white paper, case study, webinar or infographic. This info is passed into the hidden field, then on to the related field in the lead's entry in our database. It, in turn, is used to send an auto-reply that provides the file requested. So, if the user fills out the form on:

Website.com/resource-request/whitepaper-name?title=wp_whitepapername&type=white_paper

.. The title, wp_whitepapername and the type, white_paper, are passed into John Doe Lead's entry, and they get an email modified by a little scripting to say, essentially:

"Here's your<a href="go.website.com/resources/wp_whitepapername.pdf">white paper</a>"

Does that help explain enough?

SanfordWhiteman
Level 10 - Community Moderator

Re: Post field info to embedded form

You can't read POST data from the browser, so that's not going to help you. On the server side, Drupal could read POST data and re-output it into the page -- as JavaScript variables, for example, to populate the form fields -- but that certainly isn't going to solve your concern about the pages not being indexed with useful data! (In fact using POST to generate documents is guaranteed to prevent pages from being useful via GET.)

There's absolutely nothing wrong with using query parameters to pre-populate a download form (or any other kind of form). It's a standard way to do intra-site navigation with creating any extra stored state (for a counterexample, if you were to store the "next form state" in cookies, there's no way to automatically clear them out if somebody moves to another page, while the URL naturally just goes away as they move around the site).

Now, when you say "problematic" vis-a-vis same-site navigation I don't know what you mean, since the Forms 2.0 AutoFill from Query Param works very, very well (I don't know of a single case in which a well-formed URL will not work).  As for Google indexing, it sounds like you may not be presenting the pages with query params in a way that the crawler can find them, but that's a matter of SEO-type stuff.

Charles_Sander1
Level 4

Re: Post field info to embedded form

Hmmm...  I'll have to further research the Google indexing issue. I've not seen any way in our current site for modifying this. I swear I've seen somewhere to 'keep query strings' in the URL. But no luck.

For the sake of a live example - here's a real-world example:

http://cyberscout.com/resource-request/cyber-reseach-2018-sponsored-by-insurance-post-cyberscout?tit...

But google  indexed only this:

http://cyberscout.com/resource-request/cyber-reseach-2018-sponsored-by-insurance-post-cyberscout

Regarding other 'problematic' things  -- I'm referring to issues on the website unrelating to the Marketo form. This is an inherited, convoluted website with many issues -- lots of duct tape and bubble gum. I'm dying to fix things in a redesign when company budget allows, and looking for ways to streamline. I think some really hacky inconsistent things were done to make our resource pages pass  info into the URL. So, I was  hoping to avoid the whole mess if there was a way without using the URL to pass info. I'm fine continuing with the passed URL variables, if there's a way to rework everything else more efficiently and solve the Google index issue.

SanfordWhiteman
Level 10 - Community Moderator

Re: Post field info to embedded form

Hmmm... I'll have to further research the Google indexing issue. I've not seen any way in our current site for modifying this. I swear I've seen somewhere to 'keep query strings' in the URL

The query string is a part of the URL.

I'm guessing you mean in the pathname of the URL.  You could have the Drupal admin root your pages at a certain depth, after which you could use arbitrary page slugs to signify content, for example in the URL http://cyberscout.com/cyber-research-2018-sponsored-by-insurance-post-cyberscout/wp_cyberresearchrep... the full pathname is specific to (and repeats) the query string, but the page in Drupal is still the page at /cyber-research-2018-sponsored-by-insurance-post-cyberscout.

But this isn't necessary. You can use query params as long as you categorize parameters with the URL Parameters tool.

Charles_Sander1
Level 4

Re: Post field info to embedded form

A-ha! I suspect the URL Parameters tool is exactly what I needed! Didn't know that existed (or forgot). Now I just have to see what I get after the next crawl of the site. Thanks!