I was playing around with random multivariate script here: http://stmforum.com/forum/showthread...est-in-CPV-Lab
The above idea is to just generate some random numbers.
I've read through some of the threads here, and apparently random is preferred rather than using a count file, because of the R/W (read/write) activities to the server.
And since CPVLab is doing R/W to database already, I figure another simple query to get the LastView number of a campaign can be used as the count. Instead of using a count file.
<?
$username = "yourCPVLabUsername";
$password = "yourCPVLabPassword";
$hostname = "localhost";
$database = "yourCPVLabDatabase";
$campaignId = "11"; //Example ID, this can be passed via query string later on
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
echo "Connected to MySQL<br/>";
//select a database to work with
$selected = mysql_select_db($database,$dbhandle)
or die("Could not select " . $database);
//execute the SQL query and return records
$result = mysql_query("SELECT LastViews FROM campaigns WHERE CampaignId = '" . $campaignId . "' ");
//fetch the data from the database
$row = mysql_fetch_array($result);
$lastViews = $row{'LastViews'};
//close the connection
mysql_close($dbhandle);
echo "LastViews = " . $lastViews . "<br/>";
?>
So, tinkering further, I've tried using some simple MOD operand to generate some rotation based on the count (LastView).
$lastViews = 100; //Example number, this can be actually taken from the previous code
$v1_count = 5; //variate 1, for example, total of Headline Text
$v2_count = 4; //variate 2, for example, total of Image
$v3_count = 2; //variate 3, for example, total of CTA Text
echo "Example for the next 200 views<br/>";
echo "<pre><br/>";
echo "view:\tv1\tv2\tv3<br/>";
for ($i=$lastViews + 1; $i < $lastViews + 1 + 200; $i++) {
echo $i . "\t" . $i % $v1_count . "\t" . $i % $v2_count . "\t" . $i % $v3_count . "<br/>";
}
echo "</pre>";
LastViews = 100 Example for the next 200 views view: v1 v2 v3 101 1 1 1 102 2 2 0 103 3 3 1 104 4 0 0 105 0 1 1 106 1 2 0 107 2 3 1 108 3 0 0 109 4 1 1 110 0 2 0 111 1 3 1 112 2 0 0 113 3 1 1 114 4 2 0 115 0 3 1 116 1 0 0 117 2 1 1 118 3 2 0 119 4 3 1 120 0 0 0 121 1 1 1 122 2 2 0 123 3 3 1 124 4 0 0 125 0 1 1 126 1 2 0 127 2 3 1 128 3 0 0 129 4 1 1 130 0 2 0 131 1 3 1 132 2 0 0 133 3 1 1 134 4 2 0 135 0 3 1 136 1 0 0 137 2 1 1 138 3 2 0 139 4 3 1 140 0 0 0 141 1 1 1 142 2 2 0 143 3 3 1 144 4 0 0 145 0 1 1 146 1 2 0 147 2 3 1 148 3 0 0 149 4 1 1 150 0 2 0 151 1 3 1 152 2 0 0 153 3 1 1 154 4 2 0 155 0 3 1 156 1 0 0 157 2 1 1 158 3 2 0 159 4 3 1 160 0 0 0 161 1 1 1 162 2 2 0 163 3 3 1 164 4 0 0 165 0 1 1 166 1 2 0 167 2 3 1 168 3 0 0 169 4 1 1 170 0 2 0 171 1 3 1 172 2 0 0 173 3 1 1 174 4 2 0 175 0 3 1 176 1 0 0 177 2 1 1 178 3 2 0 179 4 3 1 180 0 0 0 181 1 1 1 182 2 2 0 183 3 3 1 184 4 0 0 185 0 1 1 186 1 2 0 187 2 3 1 188 3 0 0 189 4 1 1 190 0 2 0 191 1 3 1 192 2 0 0 193 3 1 1 194 4 2 0 195 0 3 1 196 1 0 0 197 2 1 1 198 3 2 0 199 4 3 1 200 0 0 0 201 1 1 1 202 2 2 0 203 3 3 1 204 4 0 0 205 0 1 1 206 1 2 0 207 2 3 1 208 3 0 0 209 4 1 1 210 0 2 0 211 1 3 1 212 2 0 0 213 3 1 1 214 4 2 0 215 0 3 1 216 1 0 0 217 2 1 1 218 3 2 0 219 4 3 1 220 0 0 0 221 1 1 1 222 2 2 0 223 3 3 1 224 4 0 0 225 0 1 1 226 1 2 0 227 2 3 1 228 3 0 0 229 4 1 1 230 0 2 0 231 1 3 1 232 2 0 0 233 3 1 1 234 4 2 0 235 0 3 1 236 1 0 0 237 2 1 1 238 3 2 0 239 4 3 1 240 0 0 0 241 1 1 1 242 2 2 0 243 3 3 1 244 4 0 0 245 0 1 1 246 1 2 0 247 2 3 1 248 3 0 0 249 4 1 1 250 0 2 0 251 1 3 1 252 2 0 0 253 3 1 1 254 4 2 0 255 0 3 1 256 1 0 0 257 2 1 1 258 3 2 0 259 4 3 1 260 0 0 0 261 1 1 1 262 2 2 0 263 3 3 1 264 4 0 0 265 0 1 1 266 1 2 0 267 2 3 1 268 3 0 0 269 4 1 1 270 0 2 0 271 1 3 1 272 2 0 0 273 3 1 1 274 4 2 0 275 0 3 1 276 1 0 0 277 2 1 1 278 3 2 0 279 4 3 1 280 0 0 0 281 1 1 1 282 2 2 0 283 3 3 1 284 4 0 0 285 0 1 1 286 1 2 0 287 2 3 1 288 3 0 0 289 4 1 1 290 0 2 0 291 1 3 1 292 2 0 0 293 3 1 1 294 4 2 0 295 0 3 1 296 1 0 0 297 2 1 1 298 3 2 0 299 4 3 1 300 0 0 0
Already sent you an answer to your PM, but I'll answer here too...
The rand() function I use in my hack will even out over time and while it might seem random at first, all variations should receive roughly the same amount of traffic.
Awesome! Thanks Andy!