Bir görüntü üzerinde Google Analytics kullanarak

0 Cevap php

Image / jpeg:. Temelde ben bunun sebebi ben HTML olmadan ancak bir Content-type gibi bir görüntü göstermek istiyorum ki (1px GIF göstermek sunucu üzerinde Google Analytics çalıştırmak ve istemiyorsanız

    $GA_ACCOUNT = "MO-3845491-5";
      $GA_PIXEL = "ga.php";

      function googleAnalyticsGetImageUrl() {
        global $GA_ACCOUNT, $GA_PIXEL;
        $url = "";
        $url .= $GA_PIXEL . "?";
        $url .= "utmac=" . $GA_ACCOUNT;
        $url .= "&utmn=" . rand(0, 0x7fffffff);

        $referer = $_SERVER["HTTP_REFERER"];
        $query = $_SERVER["QUERY_STRING"];
        $path = $_SERVER["REQUEST_URI"];

        if (empty($referer)) {
          $referer = "-";
        }
        $url .= "&utmr=" . urlencode($referer);

        if (!empty($path)) {
          $url .= "&utmp=" . urlencode($path);
        }

        $url .= "&guid=ON";

        return $url;
      }

$googleAnalyticsImageUrl = googleAnalyticsGetImageUrl();
  //echo '<img src="' . $googleAnalyticsImageUrl . '" />';
  //open the google script with all our settings to generate the 1px x 1px blank gif which reports to GA
  $handle = fopen ($googleAnalyticsImageUrl, "r");
  $test = fgets($handle);
  echo $test;
  fclose($handle);  

//Pretend this page was a jpg image all along and get the jpg and return it.
$imageurl = fopen ('http://www.default.com/test.jpg', "r"); //this is where the real file should be located
while (!feof ($imageurl)) {
 $image = fgets($imageurl, 4096);
 header('Content-type: image/jpeg');
 echo $image;
}
fclose($imageurl);

Ben GA için çok yeni olduğum gibi herhangi bir yardım büyük mutluluk duyacağız

0 Cevap