Is Google Tag Manager possible in 2021?

This forum is for all Flare issues not related to any of the other categories.
Post Reply
reserves
Jr. Propeller Head
Posts: 3
Joined: Mon Jul 05, 2021 9:51 am

Is Google Tag Manager possible in 2021?

Post by reserves »

Is there a proven way to insert the Google Tag Manager code?

Google searches have led to many solutions here on this forum which seem out of date, or are not working for me.
  • The script tag in the header currently fails on build.
    The one in the body tag gets removed completely on build
Using Flare 2021, my code is:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd">
    <head>
		<!-- Google Tag Manager -->
		<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
			new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
			j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
			'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
		})(window,document,'script','dataLayer','GTM-XXX');</script>
		<!-- End Google Tag Manager -->
    </head>
    <body>
		
		<!-- Google Tag Manager (noscript) -->
		<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXX"
		height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
		<!-- End Google Tag Manager (noscript) -->
		
        <MadCap:bodyProxy />
        <div class="home-footer">
            <table style="width: 100%;">
                <col />
                <col />
                <tbody>
                    <tr>
                        <td>
                            <p class="footer"><MadCap:variable name="General.Email" />
                            </p>
                            <p class="footer"><MadCap:variable name="General.PhoneNumber" />
                            </p>
                            <p class="footer"><MadCap:variable name="General.StreetAddress" />
                            </p>
                            <p class="footer"><MadCap:variable name="General.CityStateZip" />
                            </p>
                            <p class="footer-sub">Created Using MadCap Flare</p>
                        </td>
                        <td style="text-align: right;">
                            <img src="../Images/Logo.png" />
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </body>
</html>
thanks!
reserves
Jr. Propeller Head
Posts: 3
Joined: Mon Jul 05, 2021 9:51 am

Re: Is Google Tag Manager possible in 2021?

Post by reserves »

Seems that something quite simple isn't possible with Flare!
kmorrison
Sr. Propeller Head
Posts: 104
Joined: Mon Nov 11, 2013 3:04 pm
Location: Ottawa, Canada
Contact:

Re: Is Google Tag Manager possible in 2021?

Post by kmorrison »

Here's what we are currently using:
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-######" height="0" width="0" style="display:none;visibility:hidden"></iframe>
</noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js ... efore(j,f);
})(window,document,'script','dataLayer','GTM-######');</script>
This all goes into the master page just after the opening <body> tag and doesn't cause errors or get stripped out during the HTML5 help build. (Actual google tag manager #s replaced with ######) I assume that the code is doing what it should, since Google Analytics is tracking page views.
In case it matters, we use tripane skins for some things and side-nav skins without iframes for other things.
Vivaldi
Jr. Propeller Head
Posts: 1
Joined: Wed Sep 08, 2021 9:09 am
Location: USA

Re: Is Google Tag Manager possible in 2021?

Post by Vivaldi »

Actually, I also can't use tag manager. And I can not figure out what's the problem :?:
Hey everyone! I like to write about web and app development. Check my new article about healthcare app development to understand the basics of application development. If you have any questions and offers feel free to PM me!
lorynj
Propeller Head
Posts: 34
Joined: Mon Apr 23, 2018 6:17 pm
Location: Melbourne, Australia

Re: Is Google Tag Manager possible in 2021?

Post by lorynj »

Here’s how I place GTM in Flare.

Place the following in the page head.

Code: Select all

<!-- Google Tag Manager -->
        <script>/*<![CDATA[*/(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
			new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
			j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
			'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
		})(window,document,'script','dataLayer','XXX-XXXXXX');/*]]>*/</script>
        <!-- End Google Tag Manager -->
Loryn Jenkins
Technical Writer and Consultant
Franchise Cloud Solutions
KLAstry
Propeller Head
Posts: 19
Joined: Tue Sep 18, 2012 6:57 am

Re: Is Google Tag Manager possible in 2021?

Post by KLAstry »

In Flare 2022, I inserted this GTM code into my Home master page and Other Topics master page and it didn't break my build:

<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js ... efore(j,f);
})(window,document,'script','dataLayer','GTM-xxxxxx');</script>

Flare was choking on '&l='. Once I substituted '&l=', it worked fine.
Post Reply