Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.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
Html 在zend 2.3.5中追加脚本_Html_Zend Framework_Google Analytics - Fatal编程技术网

Html 在zend 2.3.5中追加脚本

Html 在zend 2.3.5中追加脚本,html,zend-framework,google-analytics,Html,Zend Framework,Google Analytics,在过去的几个小时里,我一直在尝试将谷歌分析添加到页面中。我想我在遵循这些文件,但这对我来说根本不起作用 我正在努力实现: <script async src="https://www.googletagmanager.com/gtag/js?id=xxxx"></script> <script> window.dataLayer = window.dataLayer || []; function gtag()

在过去的几个小时里,我一直在尝试将谷歌分析添加到页面中。我想我在遵循这些文件,但这对我来说根本不起作用

我正在努力实现:

<script async src="https://www.googletagmanager.com/gtag/js?id=xxxx"></script>
  <script>
      window.dataLayer = window.dataLayer || [];
      function gtag() { dataLayer.push(arguments); }
      gtag('js', new Date());

      gtag('config', 'xxxx');
  </script>
结果:

<script type="" src="https://www.googletagmanager.com/gtag/js?id=UA-120611634-1"></script>
<script type="text/javascript">
    //<!--
                window.dataLayer = window.dataLayer || [];
                function gtag() { dataLayer.push(arguments); }
                gtag('js', new Date());
        
                gtag('config', 'xxxx');
    //-->
</script>

//

我以前从未和Zend打过交道,但我在网上做了一些例子,结果就是行不通。如果有任何提示或帮助,我将不胜感激。

有什么问题吗?您希望向页面添加脚本文件和一些内联脚本。您的示例正好显示了这个结果(您只需要将它们组合起来)。虽然就我个人而言,我只会把这些代码粘贴到版面中,除非你只想在某些页面上使用。我可以按原样粘贴它,它会工作吗?如果这是真的,我只是浪费了3个小时
 ->appendScript("
            window.dataLayer = window.dataLayer || [];
            function gtag() { dataLayer.push(arguments); }
            gtag('js', new Date());
    
            gtag('config', 'xxxx');
            ")
<script type="text/javascript">
    //<!--
                window.dataLayer = window.dataLayer || [];
                function gtag() { dataLayer.push(arguments); }
                gtag('js', new Date());
        
                gtag('config', 'xxxx');
    //-->
</script>