Custom Data Collection

Collect data such as user IDs, product codes, shopping cart totals, or referring sources from your test and conversion pages and use it later in custom reporting. Any data that is generated using JavaScript can be collected and stored.

  1. Add a project and a test that include the pages containing the custom data you wish to collect. For example, assume that the final conversion page in an e-commerce funnel has a Webtrends Analytics meta tag that identifies the total value of a shopping cart: <meta name="WT.tx_st" content="34.99"/>
  2. Configure the page to send the stored information to Optimize. There are two methods you can use to do this:
    • In the test page markup where you placed the Optimize Setup script, include the data object argument.
      
      <script type="text/javascript">
      WTOptimize.setup({data: {myVariableName: myVariableValue}});
      </script>
                          
    • Alternatively, in Optimize, edit the test page to include a pre-processing script that captures custom data values and returns them to Optimize. Library > Pages > (Your page) > Edit Page > Step 3 Advanced: Pre-processing
      
      //jQuery Example 
      function getCartValue() {
      var wtoCartValue = 
      $('meta[name=WT.tx_st]').attr("content");
      return wtoCartValue;
      }
      var cartValue = getCartValue();  
                              
      
      //Example that is non jQuery reliant
      function getCartValue(){
       var metas = document.getElementsByTagName('meta');
       for(var m in metas){
         try{
                      if(metas[m].getAttribute('name') == 'WT.tx_st'){
                 var wtoCartValue =  metas[m].getAttribute('content');
                         return wtoCartValue;
                      }
         }catch(){}
       }
       return false;
      }
      
      var cartValue = getCartValue();  
                          
  3. Create a custom data table for the stored information.
  4. When the data table is ready for use, map the variables you named earlier to the corresponding meta fields in the table.
    1. Edit the test.Laboratory > Select a Test > Edit Test
    2. Open the test builder to the step Change advanced test options and click Visitor Data Collection.
    3. Click Add data field.
    4. Enter a page variable name. Be sure to use the same variable name you specified in the test page.
    5. Click Browse to see a list of data tables. Open one and select the data field you want to use.
    6. Click Save.
  5. Click Finish.
  6. Verify that your custom data has been sent to the Optimize object. Using Firebug's Document Object Model (DOM) panel, navigate to WTOptimize > z2b20 > 0 > zccdd > data > {Your Data}to verify that data is sent to the Optimize data object.
    Note: Custom data can be collected only in Active tests. While a test is in Staging, you can verify that your custom data is properly configured for capture, but no data will be available.