php 不使用JavaScript调用Google Analytics的简单示例

前端之家收集整理的这篇文章主要介绍了php 不使用JavaScript调用Google Analytics的简单示例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编来看看吧。
经测试代码如下:

<?PHP
/**
 * 不使用JavaScript调用Google Analytics
 *
 * @param 
 * @arrange (512.笔记) jb51.cc
 **/

$var_utmac=GOOGLE_ANALYTICS_CODE; //enter the new urchin code
$var_utmhn=WEB_DOMAIN; //enter your domain
$var_utmn=rand(1000000000,9999999999);//random request number
$var_cookie=rand(10000000,99999999);//random cookie number
$var_random=rand(1000000000,2147483647); //number under 2147483647
$var_today=time(); //today
$var_referer=$_SERVER['HTTP_REFERER']; //referer url

$var_uservar=$storeinfo["storeid"]; //enter your own user defined variable
$var_utmp="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

$urchinUrl='http://www.google-analytics.com/__utm.gif?utmwv=1&utmn='.$var_utmn.'&utmsr=-&utmsc=-&utmul=-&utmje=0&utmfl=-&utmdt=-&utmhn='.$var_utmhn.'&utmr='.$var_referer.'&utmp='.$var_utmp.'&utmac='.$var_utmac.'&utmcc=__utma%3D'.$var_cookie.'.'.$var_random.'.'.$var_today.'.'.$var_today.'.'.$var_today.'.2%3B%2B__utmb%3D'.$var_cookie.'%3B%2B__utmc%3D'.$var_cookie.'%3B%2B__utmz%3D'.$var_cookie.'.'.$var_today.'.2.2.utmccn%3D(direct)%7Cutmcsr%3D(direct)%7Cutmcmd%3D(none)%3B%2B__utmv%3D'.$var_cookie.'.'.$var_uservar.'%3B';

$handle = fopen ($urchinUrl,"r");
$test = fgets($handle);
fclose($handle);

/*** 来自:编程之家 jb51.cc(jb51.cc) ***/ 
?>
不适用JavaScript调用Google Analytics,这段代码适用于浏览器不支持JS时使用 原文链接:https://www.f2er.com/php/528799.html

猜你在找的PHP相关文章