emlog blog system traffic statistics

First of all, I used the webmaster's home to make some tricks, but it was completely impossible to proceed. The webmaster’s home statistics interface is fancy, and the traffic statistics code shows too many types of data.

So I directly used the txt file to count the number of clicks on the entire site. Then use Google Analytics to perform statistical analysis on all users.

Traffic Statistics

The first one is to count click traffic, find the footer.php file of emlog and insert the following code in the corresponding position in it.
My footer.php file is in the "/content/templates/default/footer.php" path.

<?php
    if(!file_exists("count.txt")){
    
    
        $one_file=fopen("count.txt","w+"); //建立一个统计文本,如果不存在就创建
        echo "您是第 <font color='red'><b>1</b></font>位访客"; //首次直接输出第一次
        fwrite($one_file,"1");  //把数字1写入文本
        fclose($one_file);
     }else{
    
     //如果不是第一次访问直接读取内容,并+1,写入更新后再显示新的访客数
        $num=file_get_contents("count.txt");
        $num++;
        file_put_contents("count.txt",$num);
        $newnum=file_get_contents("count.txt");
        echo"访客流量:".$newnum;
    }
?>

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_44223946/article/details/110151558