6 Replies Latest reply on Mar 27, 2018 5:05 PM by Charles Sanderson

    Post field info to embedded form

    Charles Sanderson

      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

        • Re: Post field info to embedded form
          Josh Hill

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

            • Re: Post field info to embedded form
              Charles Sanderson

              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?

            • Re: Post field info to embedded form
              Sanford Whiteman

              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.

              • Re: Post field info to embedded form
                Charles Sanderson

                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!