Correct Parameter Name to Set a Hidden Form Field Value

Colby_Schwartz
Level 2

Edit:

Hi All,

Our team is looking to capture javascript cookie information on our landing pages using hidden fields in forms 2.0. The fields we are looking to populate are the standard: Search Engine, Search String (when available), PayPerClick Keyword, UTM_Campaign, UTM_Medium, UTM_Source, UTM_term, AdGroup and Landing Page URL. I've reviewed the help article to "Set a Hidden Form Field Value" (https://community.marketo.com/MarketoArticle?id=kA050000000LH7uCAG) but am having issues finding/entering the correct Parameter Name. I am attempting to pull this information from "Cookie Value" from "Get Value From." I understand the Parameter Name has to map directly to the JS cookie but I don't know what values from the cookies to put them into the hidden fields. I have included bits of the JS cookie below. Thank you for your help.


            
              // The URL parameter that has your pay-per-click info.
              // Typically "kw" or "keyword" (depends on how you set up your PPC URLs)
              var payPerClickParameter = "keyword";
              var utmSourceParameter = "utm_source";
              var utmMediumParameter = "utm_medium";
              var utmCampaignParameter = "utm_campaign";
              var utmTermParameter = "utm_term";
              var adGroupParameter = "AdGroup";
              var landingPageUrlParameter = "LP_URL";
         
  
              // IDs for the fields to be updated. these are the form fields
              var searchStringField = "#SearchString";
              var searchEngineField = "#SearchEngine";
              var payPerClickKeywordField = "#PayPerClickKeyword";
              var utmSourceField = "#UTM_source";
              var utmMediumField = "#UTM_medium";
              var utmCampaignField = "#UTM_campaign";
              var utmTermField = "#UTM_term";
              var adGroupField = "#AdGroup";
              var landingPageUrlField = "#LandingPageURL";
    
  
                // Get the values from the cookies and put them into the hidden fields. this is where it reads the cookies.
            
            // we do this below, I don't think this is necessary
            //$jQ(searchStringField).attr("value", SearchString);
            //$jQ(searchEngineField).attr("value", searchEngine);
            //$jQ(payPerClickKeywordField).attr("value", payPerClickWord);
            //$jQ(utmSourceField).attr("value", utmSource);
            //$jQ(utmMediumField).attr("value", utmMedium);
            //$jQ(utmCampaignField).attr("value", utmCampaign);
            //$jQ(utmTermField).attr("value", utmTerm);
            //$jQ(adGroupField).attr("value", adGroup);
            //$jQ(landingPageUrlField).attr("value", landingPageUrl);
          
            // need to use Marketo forms 2.0 to get the form fields
            
            MktoForms2.whenReady(function(){
              // not sure what form to use, so we'll loop through all forms and set values
              
              var forms = MktoForms2.allForms();
              
              for(var i = 0; i < forms.length; i++) {
                var form = forms[i];
                setFormValuesFromCookie(form, {
                  'SearchString': 'SearchString',
                  'SearchEngine':'SearchEngine',
                  'PayPerClickKeyword': 'PPCKeyword',
                  'UTM_source': 'utm_source',
                  'UTM_medium': 'utm_medium',
                  'UTM_campaign': 'utm_campaign',
                  'UTM_term': 'utm_term',
                  'AdGroup': 'AdGroup',
                  'LandingPageURL': 'LandingPageURL'"
   

Tags (1)
10 REPLIES 10