【发布时间】:2014-03-05 19:54:42
【问题描述】:
是否会在标头位置重定向之前执行 Google 分析代码?如果没有,还有其他方法吗?
例子:
<html>
<body>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-0000000-0', 'domain.com');
ga('send', 'pageview');
</script>
</body>
</html>
<?php
header('Location: http://domain.com');
?>
【问题讨论】:
-
重定向必须使用 php header 301 重定向
-
-
这也是我的想法,不幸的是
标签: javascript php google-analytics http-headers