<bdo id='ajotM'></bdo><ul id='ajotM'></ul>
      <legend id='ajotM'><style id='ajotM'><dir id='ajotM'><q id='ajotM'></q></dir></style></legend>
      <tfoot id='ajotM'></tfoot>

      1. <i id='ajotM'><tr id='ajotM'><dt id='ajotM'><q id='ajotM'><span id='ajotM'><b id='ajotM'><form id='ajotM'><ins id='ajotM'></ins><ul id='ajotM'></ul><sub id='ajotM'></sub></form><legend id='ajotM'></legend><bdo id='ajotM'><pre id='ajotM'><center id='ajotM'></center></pre></bdo></b><th id='ajotM'></th></span></q></dt></tr></i><div id='ajotM'><tfoot id='ajotM'></tfoot><dl id='ajotM'><fieldset id='ajotM'></fieldset></dl></div>

        <small id='ajotM'></small><noframes id='ajotM'>

      2. 使用 Google Analytics 在网站上显示实时用户数

        时间:2023-06-23

        <small id='GD7v1'></small><noframes id='GD7v1'>

          <tfoot id='GD7v1'></tfoot>
            <tbody id='GD7v1'></tbody>

            • <bdo id='GD7v1'></bdo><ul id='GD7v1'></ul>
              <i id='GD7v1'><tr id='GD7v1'><dt id='GD7v1'><q id='GD7v1'><span id='GD7v1'><b id='GD7v1'><form id='GD7v1'><ins id='GD7v1'></ins><ul id='GD7v1'></ul><sub id='GD7v1'></sub></form><legend id='GD7v1'></legend><bdo id='GD7v1'><pre id='GD7v1'><center id='GD7v1'></center></pre></bdo></b><th id='GD7v1'></th></span></q></dt></tr></i><div id='GD7v1'><tfoot id='GD7v1'></tfoot><dl id='GD7v1'><fieldset id='GD7v1'></fieldset></dl></div>
                • <legend id='GD7v1'><style id='GD7v1'><dir id='GD7v1'><q id='GD7v1'></q></dir></style></legend>
                  本文介绍了使用 Google Analytics 在网站上显示实时用户数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何通过 Google 分析显示任何页面加载时的在线访问者数量?

                  How can I show the number of visitors online at any page load via Google analytics?

                  例如,当访问者在某处加载页面时,它会显示58 个在线访问者".

                  E.g., when a visitor loads the page somewhere it will say "58 Visitors Online".

                  推荐答案

                  正如 Trott 之前所解释的,分析中没有这样的功能.但是,我给你一个非常非常古老的选择.我是在 2004 年写的,所以它已经过时了,但基本上有效.此外,它在不使用任何数据库的情况下工作......有时你需要像这样的复古解决方案:)

                  As Trott explained before, there is no such function in analytics. However, I give you a very very old alternative. I wrote this in 2004, so its outdated, but basically works. Also, it works without using any databases.. sometimes you need retro-solutions like this :)

                  现场演示:kopli.pri.ee/stackoverflow/6976362.php

                  (您需要为当前文件夹设置 777 chmod,以便自动创建 users.dat)

                  <?php
                  $current_users_file = 'users.txt';
                  if (!file_exists($current_users_file)) fclose(fopen($current_users_file, "w"));
                  $users = file($current_users_file);
                  $found = false;
                  $user_count = count($users);
                  $fp = fopen($current_users_file, "w");
                  foreach($users as $user) {
                      $user = explode("|", $user);
                      if ($user[1]+300 < time()) {
                          $user_count--;
                          continue;
                      } elseif ($user[0] == $REMOTE_ADDR) {
                          $user[1] = time();
                          $found = true;
                      }
                      $user = trim(implode("|", $user))."
                  ";
                      fputs($fp, $user);
                  }
                  if (!$found) {
                      fputs($fp, $REMOTE_ADDR."|".time()."
                  ");
                      $user_count++;
                  }
                  fclose($fp);
                  echo 'Active users <b>' . $user_count . '</b>';
                  ?>
                  

                  这篇关于使用 Google Analytics 在网站上显示实时用户数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                    <tbody id='t1h0Z'></tbody>

                  <small id='t1h0Z'></small><noframes id='t1h0Z'>

                  <legend id='t1h0Z'><style id='t1h0Z'><dir id='t1h0Z'><q id='t1h0Z'></q></dir></style></legend>

                      <bdo id='t1h0Z'></bdo><ul id='t1h0Z'></ul>

                          <tfoot id='t1h0Z'></tfoot>
                          <i id='t1h0Z'><tr id='t1h0Z'><dt id='t1h0Z'><q id='t1h0Z'><span id='t1h0Z'><b id='t1h0Z'><form id='t1h0Z'><ins id='t1h0Z'></ins><ul id='t1h0Z'></ul><sub id='t1h0Z'></sub></form><legend id='t1h0Z'></legend><bdo id='t1h0Z'><pre id='t1h0Z'><center id='t1h0Z'></center></pre></bdo></b><th id='t1h0Z'></th></span></q></dt></tr></i><div id='t1h0Z'><tfoot id='t1h0Z'></tfoot><dl id='t1h0Z'><fieldset id='t1h0Z'></fieldset></dl></div>