~ overflow ~

Tag: fake

Faking Google Analytics Statistics

by z3n on Jun.17, 2009, under Coding, Tips & Hints

Problem:

Let’s assume you want to build up fake statistics on google analytics using a php script.

Solution:

You just need to input the google analytics UA code and you’re ready to go:

  1.  
  2. // (c) z3n – R1V1@090617 – z3n666@gmail.com – www.overflow.biz
  3.  
  4. // Fake Resolutions
  5. $resolutions=array("1024×768","1280×800","1280×1024","1440×900","1680×1050");
  6. // Fake Flash Versions
  7. $flash=array("10.0%20r2","10.0%20r1","9.0%20r12");
  8. // Fake Languages
  9. $languages=array("en-us","de","ja","ko","pt-br");
  10.  
  11. // functions
  12.  
  13. function baseurl($x) { //v1.03
  14.  $y=str_replace("http://","",$x);
  15.  $s=strpos($y,"/");
  16.  if ($s === false) {
  17.   $s=strpos($y,"?");
  18.  }
  19.  if ($s !== false) {
  20.   $y=substr($y,0,$s);
  21.  }
  22.  return "http://".$y;
  23. }
  24. function getmicrotime() { list($usec, $sec) = explode(" ",microtime());return ((float)$usec + (float)$sec); }
  25. function ga_fake($url,$ua) {
  26.  global $resolutions,$flash,$languages;
  27.  $gmt=round(getmicrotime(),0); // timestamp
  28.  $uid=mt_rand(70710490,92710490); // unique id number
  29.  $bid=mt_rand(21234567,91234567).mt_rand(1018864,9999999).mt_rand(1021,9999); // big random number
  30.  $java=(rand(0,100) > 85) ? 0 : 1; // java enabled?
  31.  $x="http://www.google-analytics.com/__utm.gif?utmwv=4.3&utmn=".mt_rand(64045995,94045995)."&utmhn=".str_replace("http://","",baseurl($url))."&utmcs=ISO-8859-1&utmsr=".$resolutions[array_rand($resolutions,1)]."&utmsc=32-bit&utmul=".$languages[array_rand($languages,1)]."&utmje=".$java."&utmfl=".$flash[array_rand($flash,1)]."&utmhid=".mt_rand(1650046796,1890046796)."&utmr=-&utmp=".str_replace(baseurl($url),"",$url)."&utmac=".$ua."&utmcc=__utma%3D".$uid.".".$bid.".".$gmt.".".$gmt.".".$gmt.".1%3B%2B__utmz%3D".$uid.".".$gmt.".1.1.utmcsr%3D(direct)%7Cutmccn%3D(direct)%7Cutmcmd%3D(none)%3B";
  32.  @file_get_contents($x);
  33. }
  34.  
  35. // now you just need to call it
  36.  
  37. ga_fake("http://someurl/where/the/hit/happened/","UA-123456-78");
1 Comment :, , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!