简体   繁体   English

无法在 MadCap Flare 项目的 MasterPage 中添加脚本异步

[英]Cannot add script async in MasterPage of MadCap Flare project

I am trying to add Google Analytics tag to all the pages in a MadCap Flare project.我正在尝试将 Google Analytics 标签添加到 MadCap Flare 项目中的所有页面。

The way to do this is to add the tag to de MasterPage, but MadCap Flare does not allow me to add the Google tag.这样做的方法是将标签添加到 de MasterPage,但 MadCap Flare 不允许我添加 Google 标签。 If I remove the async attribute it works, but I think it is not a good idea:如果我删除它的异步属性,但我认为这不是一个好主意: 在此处输入图像描述

If I try to add this snippet to the target configuration, I have also an error:如果我尝试将此代码段添加到目标配置中,我也会遇到错误: 在此处输入图像描述

In both ways MadCap Flare does not allow me to save the changes.在这两种方式中,MadCap Flare 都不允许我保存更改。

NOTE : I am using MadCap Flare 2017 r3 (could be a bug in this version?)注意:我使用的是 MadCap Flare 2017 r3(可能是这个版本的错误?)

XHTML requires to use async="async" there, it should probably solve your issue. XHTML 需要在那里使用async="async" ,它应该可以解决您的问题。

We're using a variable for the tracking code in our masterpage so our script looks like this:我们在母版页中使用跟踪代码的变量,因此我们的脚本如下所示:

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

            gtag('config', '[%=Products.TRACKINGCODE%]');
        </script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM