Binom Documentation

К навигации

Multivariate Testing

Sometimes simple A/B testing is not enough for effective landing analyze and in this case multivariate testing (MVT) can help. Its main advantage is the ability to combine different versions of images, buttons, texts and other elements inside one page, and the statistics in the tracker will help you to find best variant.

Setup

In order to see the stats you have to use LP Tokens or Events and our randomization code.
Landing should be with .php extension and contain the following code at the very beginning (before <!DOCTYPE html> and etc):

                                
                                    <?php
                                        function getRandomElement( $arr ){
                                            $keys = array_keys($arr);
                                            $len = count( $keys );
                                            $rand = mt_rand( 0, $len-1 );
                                            $index = $keys[$rand];
                                            return [$index, $arr[ $index ]];
                                        }
                                        function makeUpdateTokenURL( $TRACKER_URL, $indexes ){
                                            $s = $TRACKER_URL.'/click.php?lp=data_upd&';
                                            foreach ($indexes as $tokenName => $tokenValue) {
                                                $s .= "{$tokenName}={$indexes[$tokenName]}&";
                                            }
                                            $s = rtrim($s, "&");
                                            return $s;
                                        }
                                        function getChosen( $blockSet, $randomOptions ){
                                            $indexes = array();
                                            $result = array();
                                            foreach ($blockSet as $blockName=>$values) {
                                                $indexes[$blockName] = [];
                                                $result[$blockName]  = [];
                                            
                                                if ( !isset($randomOptions[$blockName]) || $randomOptions[$blockName]==="random" ){
                                                    list($index, $element) = getRandomElement( $values );
                                                } else {
                                                    $index   = $randomOptions[$blockName];
                                                    $element = $values[$index];
                                                }
                                            
                                                $indexes[$blockName] = $index;
                                                $result[$blockName]  = $element;
                                            }
                                            return [ $indexes, $result ];
                                        }
                                
                            
Then, you need to add the main part with your content options. For example, you want to test 3 different headers, 3 different pictures and 3 different iframe:
                                
                                    // Your tracker's domain 
                                    $TRACKER_DOMAIN = 'http://tracker.com';
                                    
                                    // Specify name of LP token for tracker, its value and code content of the main page
                                    $bricks = [
                                        // First token header and it's options 
                                        'header'=> [ 
                                            "1" => '<h1>Test 1</h1>',
                                            "2" => '<h1>Test 2</h1>',
                                            "3" => '<h1>Test 3</h1>'
                                        ],
                                        // Second token wallpaper and it's options 
                                        'wallpaper'=> [
                                            "1" => '<img src="images/wallpaper-1.png">', 
                                            "2" => '<img src="images/wallpaper-2.png">',
                                            "3" => '<img src="images/wallpaper-3.png">'
                                        ],
                                        // Third token Font-color and it's options 
                                        'font-color'=> [ 
                                            "Green" => '#41f449', 
                                            "Yellow" => '#f4f141', 
                                            "Red" => '#f44242'
                                        ]
                                    ];
                                
                            
Now you need to choose to substitute elements randomly or to fix a specific option. This may be useful, for example, when you have found best option.
                                
                                        $randomOptions = [
                                            // Only first header 
                                            "header" => 1,
                                            // All variants
                                            "wallpaper"   => "random",
                                            "font-color" => "random",
                                        ];
                                
                            
Next, you need to add another block (nothing to change here):
                                
                                        list( $indexes, $result ) = getChosen( $bricks, $randomOptions );
                                        
                                        $updateTokensURL = makeUpdateTokenURL( $TRACKER_DOMAIN, $indexes );
                                        
                                        $updateLPTokensScript = <<<EOT
                                        <script type="text/javascript">
                                        var o = document.createElement("img");
                                        o.src="{$updateTokensURL}";
                                        </script>
                                    EOT;
                                    ?>
                                
                            
In the end, you need to add the main code of your page with relevant content:
                                
                                        <!DOCTYPE html>
                                        <html>
                                        <head>
                                            <title>Test!</title>
                                            <!-- Send data to tracker -->
                                            <?php echo $updateLPTokensScript; ?>
                                        </head>
                                        <body>
                                            <h1>
                                                <!-- Specify first element -->
                                                <?= $result["header"]; ?>
                                            </h1>
                                            <!-- Second -->
                                            <?= $result["wallpaper"]; ?>
                                            <!-- Third -->
                                            <a style="color:<?= $result["font-color"]; ?>;font-size:300%;text-decoration-line:none" href="http://tracker.com/click.php?lp=1"> Link to the offer </a>
                                        </body>
                                        </html>
                                
                            

Finally you will get php-file with this:
  • Final code sample
    •                                                     
                                                              <?php
                                                                  function getRandomElement( $arr ){
                                                                      $keys = array_keys($arr);
                                                                      $len = count( $keys );
                                                                      $rand = mt_rand( 0, $len-1 );
                                                                      $index = $keys[$rand];
                                                                      return [$index, $arr[ $index ]];
                                                                  }
                                                                  function makeUpdateTokenURL( $TRACKER_URL, $indexes ){
                                                                      $s = $TRACKER_URL.'/click.php?lp=data_upd&';
                                                                      foreach ($indexes as $tokenName => $tokenValue) {
                                                                          $s .= "{$tokenName}={$indexes[$tokenName]}&";
                                                                      }
                                                                      $s = rtrim($s, "&");
                                                                      return $s;
                                                                  }
                                                                  function getChosen( $blockSet, $randomOptions ){
                                                                      $indexes = array();
                                                                      $result = array();
                                                                      foreach ($blockSet as $blockName=>$values) {
                                                                          $indexes[$blockName] = [];
                                                                          $result[$blockName]  = [];
                                                                      
                                                                          if ( !isset($randomOptions[$blockName]) || $randomOptions[$blockName]==="random" ){
                                                                              list($index, $element) = getRandomElement( $values );
                                                                          } else {
                                                                              $index   = $randomOptions[$blockName];
                                                                              $element = $values[$index];
                                                                          }
                                                                      
                                                                          $indexes[$blockName] = $index;
                                                                          $result[$blockName]  = $element;
                                                                      }
                                                                      return [ $indexes, $result ];
                                                                  }
                                                                  // Your tracker's domain 
                                                                  $TRACKER_DOMAIN = 'http://tracker.com';
                                                                  
                                                                  // Specify name of LP token for tracker, its value and code content of the main page
                                                                  $bricks = [
                                                                      // First token header and it's options 
                                                                      'header'=> [ 
                                                                          "1" => '<h1>Test 1</h1>',
                                                                          "2" => '<h1>Test 2</h1>',
                                                                          "3" => '<h1>Test 3</h1>'
                                                                      ],
                                                                      // Second token wallpaper and it's options 
                                                                      'wallpaper'=> [
                                                                          "1" => '<img src="images/wallpaper-1.png">', 
                                                                          "2" => '<img src="images/wallpaper-2.png">',
                                                                          "3" => '<img src="images/wallpaper-3.png">'
                                                                      ],
                                                                      // Third token Font-color and it's options 
                                                                      'font-color'=> [ 
                                                                          "Green" => '#41f449', 
                                                                          "Yellow" => '#f4f141', 
                                                                          "Red" => '#f44242'
                                                                      ]
                                                                  ];
                                                                  $randomOptions = [
                                                                          // Only first header 
                                                                          "header" => 1,
                                                                          // All variants
                                                                          "wallpaper"   => "random",
                                                                          "font-color" => "random"
                                                                  ];
                                                                  list( $indexes, $result ) = getChosen( $bricks, $randomOptions );
                                                                  
                                                                  $updateTokensURL = makeUpdateTokenURL( $TRACKER_DOMAIN, $indexes );
                                                                  
                                                                  $updateLPTokensScript = <<<EOT
                                                              <script type="text/javascript">
                                                              var o = document.createElement("img");
                                                              o.src="{$updateTokensURL}";
                                                              </script>
                                                              EOT;
                                                              ?>
                                                              <!DOCTYPE html>
                                                              <html>
                                                              <head>
                                                                  <title>Test!</title>
                                                                  <!-- Send data to tracker -->
                                                                  <?php echo $updateLPTokensScript; ?>
                                                              </head>
                                                              <body>
                                                                  <h1>
                                                                      <!-- Specify first element -->
                                                                      <?= $result["header"]; ?>
                                                                  </h1>
                                                                  <!-- Second -->
                                                                  <?= $result["wallpaper"]; ?>
                                                                  <!-- Third -->
                                                                  <a style="color:<?= $result["font-color"]; ?>;font-size:300%;text-decoration-line:none" href="http://tracker.com/click.php?lp=1"> Link to the offer </a>
                                                              </body>
                                                              </html>