Cannot add script async in MasterPage of MadCap Flare project

255 Views Asked by At

I am trying to add Google Analytics tag to all the pages in a MadCap Flare project.

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. If I remove the async attribute it works, but I think it is not a good idea: enter image description here

If I try to add this snippet to the target configuration, I have also an error: enter image description here

In both ways MadCap Flare does not allow me to save the changes.

NOTE: I am using MadCap Flare 2017 r3 (could be a bug in this version?)

1

There are 1 best solutions below

0
On

XHTML requires to use async="async" there, it should probably solve your issue.

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>