3 Replies Latest reply on Oct 15, 2015 7:29 PM by bhawkins1

    Capture Form-field Value using Script Profile

    MktgCloudUser Level 1

      Hello,

      I'd like to capture a form field value while not tied to a campaign or offer.  For example, every time page1.html is rendered, capture the "country" form-field and store it to a User Profile.  The reason I don't want to use a campaign/offer is I only have a single mbox on the page and I don't want to prevent entry into real campaigns just to capture this value.  I'm thinking the script profile would look something like this:

      On Page Code

      <input type="text" name="countryField" id="flowCountryField">

      Example Script Profile

       
      if (mbox.name == ('global') && (page.url.indexOf('/page1.html')>-1) ) { return // Here's where I'd want to capture the form field; }

      How do I modify the script above to accomplish this?  If this isn't possible, is there another way to capture this information via Target without using a campaign/offer?

      • 0. Re: Capture Form-field Value using Script Profile
        bhawkins1

        Hi there, 

        Plug-ins are snippets of code that you want to run alongside any and all tests or with mboxes for that matter.  They are independent of all test which is the key benefit.  While offers are used to generate a plug-in it is best to think of offers solely as code that you would use in a campaign. 

        Debugging plugins is accomplished much the same way you would debug an offer (content used in a test).  You can simply identify any javascript errors and address as needed.  If you look at the mbox response back to the page via a network sniffer, you can see your plug-in code respond to the page. 

        As for the profiles, within the Adobe Target interface, profiles are differentiated from profiles passed to an mbox with the syntax user. vs. via the mbox where they are called profile..  WIthin the user. or the profile setting section within the interface, you can use any and all information the mbox sees to set a profile.  

        Here are two examples of scripts that you can use within the interface:

        1. This first one sets a profile when someone makes a purchase or when the orderConfirmPage mbox is seen.  It also increments so if someone were to purchase on two separate occasions, you could target and segment them.  

        if (mbox.name == 'orderConfirmPage') {
        return (user.get('purchasefrequency') | 0) + 1;
        }

        2. This profile puts visitors into buckets based off how much they spent as that value is something that is passed to the thank you mbox.  Here you can target or segment high spenders from low spenders. 


        if (mbox.name == ('orderConfirmPage')) {
          var total = mbox.param('orderTotal');
         if (total >= 100)
         return 'high';
        else if (total >=50)
         return 'medium';
        else if (total >= 25)
         return 'low';
        else
         return 'unknown';
        }

        I hope this helps.

         

        Brian 

          • 1. Re: Capture Form-field Value using Script Profile
            MktgCloudUser Level 1

            Thanks Brian,

            I like the idea of using a regular offer that gets loaded by a plug-in - seems much more flexible than straight script parameters (makes me wonder why not convert all over to offers).  One question though, I'm having trouble finding the syntax and code examples of interacting with mboxes and the user/profile values in the T&T help.

            I know how to retrieve a user/profile parameter in an offer - ${user.paramName} - but how to you set a new value?  On this page - http://microsite.omniture.com/t2/help/en_US/tnt/help/r_variables_profiles_parameters_metho ds.html it says you can use the following - but it's supposedly only for Profile Script usage.

            user.setLocal('param_name','value');

            So is it as easy as ${user.setLocal('country', jsVariable);}

            Also, what's the best way to debug plugins?

            • 2. Re: Capture Form-field Value using Script Profile
              bhawkins1 Level 2

              Hi there, 

              Profile attributes such as the user. ones that you are highlighting are able to set profile attributes based on information passed or collected by the mbox itself.  The mbox sees the referring URL, current URL, and anything else passed to it.  Take a look at the mbox on this page and on the submit page.  It might be getting the Country ID via a referring URL but doubtful.  If so you are home.  

              The other option and more to the heart of your question is to use the Target Plug-ins.  These run independently of any campaign or activity.  Here you would create an HTML offer that would be javascript that would parse through your page and grab this value for you.  

              Hope this helps. 

              Brian