在同一个地方管理 所有 google analytic 帐号


我已经把6个网站全部都移动到同一台VPS上, 这样为了更好的管理 GOOGLE ANA帐号 可以在所有网站目录都可以访问得到的一个公共目录下 如: /home/googleana.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  $google_ana['steakovercooked.com'] = 'UA-XXXX';
  $google_ana['rot47.net'] = 'UA-XXXX';
  $google_ana['helloacm.com'] = 'UA-XXXX1';
  $google_ana['codingforspeed.com'] = 'UA-XXXX';
  $google_ana['uploadbeta.com'] = 'UA-XXXX';
  $google_ana['justyy.com'] = 'UA-XXXX';
  $current_domain = strtolower($_SERVER['HTTP_HOST']);
  $google_ana_id = $google_ana[$current_domain];
 
  function insert_google_ana() {
    global $google_ana_id;
    echo "
       <script language='Javascript'>\n
      
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '$google_ana_id']);
_gaq.push(['_trackPageview']);
 
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
 
       </script>
    ";
  }
  $google_ana['steakovercooked.com'] = 'UA-XXXX';
  $google_ana['rot47.net'] = 'UA-XXXX';
  $google_ana['helloacm.com'] = 'UA-XXXX1';
  $google_ana['codingforspeed.com'] = 'UA-XXXX';
  $google_ana['uploadbeta.com'] = 'UA-XXXX';
  $google_ana['justyy.com'] = 'UA-XXXX';
  $current_domain = strtolower($_SERVER['HTTP_HOST']);
  $google_ana_id = $google_ana[$current_domain];

  function insert_google_ana() {
    global $google_ana_id;
    echo "
       <script language='Javascript'>\n
      
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '$google_ana_id']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

       </script>
    ";
  }

存上不同网站的 帐号 这样只需要用的时候只需要 调用:

1
2
3
4
<?php
  require_once("/home/googleana.php");
  insert_google_ana();
?>
<?php
  require_once("/home/googleana.php");
  insert_google_ana();
?>

即可. 这样的好处是在同一个地方就可以管理所有的帐号 当然同样的 稍做修改 就可以应用到 google adsense 或者其它类型的代码上.

英文: https://helloacm.com/manage-google-analytics-account-in-one-place/

GD Star Rating
loading...
本文一共 139 个汉字, 你数一下对不对.
在同一个地方管理 所有 google analytic 帐号. (AMP 移动加速版本)
上一篇: 英国剑桥值得去吃和玩的地方
下一篇: 多IP设置SSL 的 SNI问题

扫描二维码,分享本文到微信朋友圈
173d9af28fcf61895a72fda42daf7b22 在同一个地方管理 所有 google analytic 帐号 互联网 技术 折腾 程序设计 网站信息与统计

评论