Skip to end of metadata
Go to start of metadata

Using Evergage you can enrich the data passed to Marketo upon form submission through a campaign thats sends additional information to Marketo in hidden fields. Your visitors won't see this information presented in the form, but it will be associated with each profile. For example, you could pass behavioral intent data, such as a visitor's favorite solution, or firmographic data from companies who have visited your site.  

This Article Explains

This article includes instructions for using a sample code block to send data to Marketo using hidden fields.

Sections in this Article

Create a New Campaign

  1. Log into Evergage with Campaign Author or higher permissions
  2. Create a new web campaign
  3. Click to create a new message
  4. Click to edit Message Settings
  5. Select Invisible Message
  6. Expand the Message Source Code panel at the bottom
  7. Select Message Source Code
  8. Select JAVASCRIPT
  9. Copy the source code below and paste it into the window
  10. Click APPLY
  11. Select SETUP
  12. Select EXPERIENCES
  13. Set the Control percentage to 0 to ensure that hidden field data for every visitor is completed
  14. Click SAVE to save your campaign


Once you save this campaign, if you need to edit the message source code, you must select Changes then click </> next to the Invisible Popup message. This action will automatically open the Message Source Code panel and bring you to the JAVASCRIPT section.



Edit the JavaScript Source Code

You will need to replace certain aspects of the code with your own variables. Start by defining the variables you will use at the top of the code block. These should be based on your own catalog dimensions. Lines 1-3 of the code shown below use ADMC with a Velocity syntax.

If one of the variables set by Evergage doesn't have a value, the data that Evergage is appending will not submit. Your form will submit regardless of whether the variables have been set. For example, if no one has viewed any products, so there are no favorite products, then the category and dimension will not be sent, but the rest of the form will submit as expected.

  • #set - if you want to bring in items from your catalog or user attributes (i.e. UTM parameters), use this function to define them

  • MktoForms2 - this is the name of the form you are using. Change this to match the name of the form you are using (e.g. "EvergageForm" or "WebForm")
  • id^= - this is defining the form. In this example, this is looking for anything with a name starting with "mktoform" so the form "MktoForms2" would be called
  • if (MktoFormObj.length > 0) - if the Marketo Form object exists (>0) then set the variable of variable 1
  • yourProduct or yourDimension - these are what you defined with #set at the top of the code block. This section is saying that if the dimension appears on the page (and it may not appear on every page), set it to be whatever the dimension name is; if it is blank then leave it blank
  • MktoForms2.whenRendered - this is telling Marketo that once it renders the form, get the form ID and submit the following hidden fields. The category1...category4


Sample Marketo Hidden Fields Code
/* #set ($yourCategory = $tools.user.categories.viewTime($itemOptions.time($time.lastNDays(30)))[0]) */
/* #set ($yourProduct = $tools.user.products.viewTime($itemOptions.time($time.lastNDays(30)))[0]) */
/* #set ($yourDimension = $tools.user.dimensions.yourProduct3.viewCount()[0]) */


Evergage.util.runWhenReady(
    function() {
        return ( window.MktoForms2 && typeof window.MktoForms2.loadForm === "function");
    },
    function() {
        var mktoFormObj = ajq("form[id^='mktoForm_']");
        
        if (mktoFormObj.length > 0){
            
            var locationCategory = "$locationCategory.id";
            var firstPipe = locationCategory.indexOf("|");
            var secondPipe = locationCategory.indexOf("|", firstPipe+1);
            var region = locationCategory.substring(0, firstPipe);
            var country = locationCategory.substring(firstPipe+1, secondPipe);
            
            var yourProduct = "$yourProduct.name";
            var yourDimension = "$yourDimension.id";
            if (yourDimension === "\$yourDimension.id") {
                yourDimension = "";
            }
            
        }
        
        MktoForms2.whenRendered(function(form){
            var formId = form.getId();
            var mktoForm = MktoForms2.getForm(formId);
           
            mktoForm.addHiddenFields({
                "Category1": country,
                "Category2": yourDimension,
                "Category3": region,
                "Category4": yourProduct
            });


        });    
    }
);