Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在每个页面中添加javascript代码?_Php_Wordpress_Google Analytics - Fatal编程技术网

Php 如何在每个页面中添加javascript代码?

Php 如何在每个页面中添加javascript代码?,php,wordpress,google-analytics,Php,Wordpress,Google Analytics,我想在网站中使用“谷歌分析” 现在我配置了我的谷歌分析。但最后它告诉我“这是你的跟踪代码。复制并粘贴到你想要跟踪的每个页面的代码中。” 给定的代码是: <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),

我想在网站中使用“谷歌分析”

现在我配置了我的谷歌分析。但最后它告诉我“这是你的跟踪代码。复制并粘贴到你想要跟踪的每个页面的代码中。”

给定的代码是:

<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-42279086-1', 'xyz.in');
  ga('send', 'pageview');

</script>

(函数(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]| |函数(){
(i[r].q=i[r].q | |[]).push(参数)},i[r].l=1*新日期();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(窗口,文档,“脚本”,“www.google-analytics.com/analytics.js”,“ga”);
ga(“创建”、“UA-42279086-1”、“xyz.in”);
ga(‘发送’、‘页面浏览’);
我已经上传了我的网站现在我怎么能做到这一点,有什么想法吗

我需要这个解决方案的java,.net和php语言,也为wordpress博客请告诉我,如果你知道

参考资料:


最简单的解决方案:安装并将跟踪钥匙
UA-42279086-1
置于其配置中


一个稍微复杂的解决方案:将
标记粘贴到您正在使用的模板中。

最简单的解决方案:安装并将跟踪键
UA-42279086-1
置于其配置中


一个稍微复杂的解决方案:将
标记粘贴到您正在使用的模板中。

将此脚本保存为文件,并将其链接到每个文档,如下所示:

<script src="path_to_file.js"></script>

将此脚本另存为文件,并将其链接到每个文档,如下所示:

<script src="path_to_file.js"></script>


我不确定wordpress的设置本身,但是如果您能够编辑模板本身,您可以将其粘贴到底部。或者,如果你可以在每个页面上添加任意HTML块,那么你可以将其粘贴到那里,并将其添加到每个页面的页脚。

我不确定wordpress设置本身,但如果你有能力编辑模板本身,你可以将其粘贴到底部。或者,如果您可以在每个页面中添加任意HTML块,然后您可以将其粘贴到那里,并将其添加到每页的页脚。

在WordPress和php站点的header.php文件中的closing head标记之前添加代码。我建议您无论如何创建一个header.php文件,并将所有head和HTML header div&navigation等放在其中,然后使用include在其他页面上函数

在WordPress和php站点的header.php文件中的closing head标记之前添加代码,我建议您无论如何创建一个header.php文件,并将所有head和HTML header div&navigation等放在其中,然后使用include函数包含在其他页面上

我已经知道我们可以使用母版页。回答我除了母版页或模板之外的任何建议。我已经知道我们可以使用母版页添加此javascript代码。请回答除母版页或模板以外的任何建议。。