Google Tag Manager Code - Flare Error
-
- Propeller Head
- Posts: 19
- Joined: Thu Nov 27, 2014 9:58 am
Google Tag Manager Code - Flare Error
Hi,
I'm hoping someone can help with some Google Tag Manager code that Flare doesn't like.
I've been asked by our Marketing dept to add the following script to the <body> tag of all of my pages in HTML 5 output (not the <head> tag as you do with Google Analytics).
I added the script to my masterpage but Flare doesn't like it and displays the error '=' is an unexpected token. The expected token is ';'. See attached ErrorCode.png. Flare then crashed.
I then added the script in Flare using Insert - Script. Flare was happy with this code: See attached NoErrorCode.png
but when I output to HTML 5, the following characters appeared at the top of every page. See CharsInOutput.png attached.
I've tried putting the code in the <body> tag and it still shows the same behaviour.
Has anyone seen this before? Any help would be really appreciated.
Thanks,
Susan.
I'm hoping someone can help with some Google Tag Manager code that Flare doesn't like.
I've been asked by our Marketing dept to add the following script to the <body> tag of all of my pages in HTML 5 output (not the <head> tag as you do with Google Analytics).
I added the script to my masterpage but Flare doesn't like it and displays the error '=' is an unexpected token. The expected token is ';'. See attached ErrorCode.png. Flare then crashed.
I then added the script in Flare using Insert - Script. Flare was happy with this code: See attached NoErrorCode.png
but when I output to HTML 5, the following characters appeared at the top of every page. See CharsInOutput.png attached.
I've tried putting the code in the <body> tag and it still shows the same behaviour.
Has anyone seen this before? Any help would be really appreciated.
Thanks,
Susan.
You do not have the required permissions to view the files attached to this post.
Re: Google Tag Manager Code - Flare Error
That's because you've inserted the whole HTML code and the javascript.
In your master page, only copy and paste the <noscript> ... </noscript> part.
Then insert the script in Flare, but only include the actual javascript - i.e. the bit that's inside the <script>...</script> tags.
In your master page, only copy and paste the <noscript> ... </noscript> part.
Then insert the script in Flare, but only include the actual javascript - i.e. the bit that's inside the <script>...</script> tags.
-
- Propeller Head
- Posts: 19
- Joined: Thu Nov 27, 2014 9:58 am
Re: Google Tag Manager Code - Flare Error
Thank-you very much Dave!
It's all working fine now.
Susan.
It's all working fine now.
Susan.
-
- Propeller Head
- Posts: 19
- Joined: Thu Nov 27, 2014 9:58 am
Re: Google Tag Manager Code - Flare Error
Hi,
Looks lile I spoke too soon. Apparently Google Tag Manager is not picking this up. Here's the code I've put in:
and here's the original code I was given by the marketing department that Flare doesn't like (but apparently works ok when placed in 'Help to Manual'.
Any ideas much appreciated?? Thanks![Smile :-)](./images/smilies/icon_smile.gif)
Susan.
Looks lile I spoke too soon. Apparently Google Tag Manager is not picking this up. Here's the code I've put in:
Code: Select all
<noscript><iframe src="file://www.googletagmanager.com/ns.html?id=GTM-M897H7" height="0" width="0" style="display:none;visibility:hidden"></iframe>
</noscript>
<p>
<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='//www.googletagmanager.com/gtm.js?id=' i dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-M897H7');/*]]>*/</script>
and here's the original code I was given by the marketing department that Flare doesn't like (but apparently works ok when placed in 'Help to Manual'.
Code: Select all
<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-M897H7" 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='//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-M897H7');</script>
<!-- End Google Tag Manager -->
Any ideas much appreciated?? Thanks
![Smile :-)](./images/smilies/icon_smile.gif)
Susan.
Re: Google Tag Manager Code - Flare Error
Hello, I'm having a similar issue with google tag manager. I no longer have an error in Flare when using the following code in my Master page, however I'm not getting any data in Google analytics for my page. Has anyone successfully used GTM code in Madcap?
Code: Select all
<head>
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-MFNLMW" height="0" width="0" style="display:none;visibility:hidden"></iframe>
</noscript>
</head>
<body>
<p>
<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= '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-MFNLMW');/*]]>*/</script>
</p>
<div class="TopicContent">
<MadCap:bodyProxy />
</div>
</body>
Re: Google Tag Manager Code - Flare Error
Also interested in seeing if anyone else has had success using GTM... I am receiving the same errors when trying to add GTM code to pages.
Re: Google Tag Manager Code - Flare Error
We did get GTM to work, but found the answer was to import the script rather than code it directly into the Master. The old Google code worked fine within our Master, but the new has not.
I also found that loading it at the bottom of the page made the page-load time MUCH better and I highly recommend it. So our master looks something like the following.
<body>
<MadCap:breadcrumbsProxy style="margin-left: -17px;margin: -17px;margin-top: 0px;margin-bottom: 0px;padding-left: 10px;margin-right: -100px;border-right: solid 20px #323232;" />
<MadCap:bodyProxy />
<p> </p>
<footer>
<MadCap:snippetBlock src="../Snippets/MasterFooter.flsnp" />
</footer>
<!-- Google Tag Manager -->
<noscript><iframe src="http://www.googletagmanager.com/ns.html?id=GTM-NMSQ7Z" height="0" width="0" style="display:none;visibility:hidden"></iframe>
</noscript>
<script src="../scripts/googleanalytics-new.js">
</script>
<!-- End Google Tag Manager -->
</body>
I also found that loading it at the bottom of the page made the page-load time MUCH better and I highly recommend it. So our master looks something like the following.
<body>
<MadCap:breadcrumbsProxy style="margin-left: -17px;margin: -17px;margin-top: 0px;margin-bottom: 0px;padding-left: 10px;margin-right: -100px;border-right: solid 20px #323232;" />
<MadCap:bodyProxy />
<p> </p>
<footer>
<MadCap:snippetBlock src="../Snippets/MasterFooter.flsnp" />
</footer>
<!-- Google Tag Manager -->
<noscript><iframe src="http://www.googletagmanager.com/ns.html?id=GTM-NMSQ7Z" height="0" width="0" style="display:none;visibility:hidden"></iframe>
</noscript>
<script src="../scripts/googleanalytics-new.js">
</script>
<!-- End Google Tag Manager -->
</body>
-
- Propellus Maximus
- Posts: 574
- Joined: Tue Oct 03, 2006 7:56 am
- Location: Seattle, WA
- Contact:
Re: Google Tag Manager Code - Flare Error
Potentially related thread, FYI: viewtopic.php?f=9&t=28892&p=126474#p126474
Pamela Denchfield
http://www.pameladenchfield.com
http://www.pameladenchfield.com
Re: Google Tag Manager Code - Flare Error
My marketing team asked me to update the GA code that we've been using, but like others, Flare isn't liking some of the code.
I have it working based on what I've been able to find in the forums, but I'm still confused b/c I don't know if what I did is correct.
My help can build, but what is supposed to go in the .js file that I see is being referenced by some of your code? That's what I don't understand.
../scripts/googleanalytics-new.js
I had put the following code in the header, but the first <script> code is the one that Flare isn't liking. And then I put it within <noscript> as described in one of the replies, and it works fine.
But b/c I'm, confused about the ../scripts/googleanalytics-new.js I ended up copying what is on the google-link to a .js file and also including a <script> line that calls the .js file.
I think I took out any company info from this code, so if anyone can help me, I'd appreciate it.
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https:/google-link"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA account');
</script>
I have it working based on what I've been able to find in the forums, but I'm still confused b/c I don't know if what I did is correct.
My help can build, but what is supposed to go in the .js file that I see is being referenced by some of your code? That's what I don't understand.
../scripts/googleanalytics-new.js
I had put the following code in the header, but the first <script> code is the one that Flare isn't liking. And then I put it within <noscript> as described in one of the replies, and it works fine.
But b/c I'm, confused about the ../scripts/googleanalytics-new.js I ended up copying what is on the google-link to a .js file and also including a <script> line that calls the .js file.
I think I took out any company info from this code, so if anyone can help me, I'd appreciate it.
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https:/google-link"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA account');
</script>
Re: Google Tag Manager Code - Flare Error
To get Google Analytics working using the 'GTAG' code (the new code it's used since around Aug 2017).devangee wrote:My marketing team asked me to update the GA code that we've been using, but like others, Flare isn't liking some of the code.
I have it working based on what I've been able to find in the forums, but I'm still confused b/c I don't know if what I did is correct.
My help can build, but what is supposed to go in the .js file that I see is being referenced by some of your code? That's what I don't understand.
../scripts/googleanalytics-new.js
I had put the following code in the header, but the first <script> code is the one that Flare isn't liking. And then I put it within <noscript> as described in one of the replies, and it works fine.
But b/c I'm, confused about the ../scripts/googleanalytics-new.js I ended up copying what is on the google-link to a .js file and also including a <script> line that calls the .js file.
I think I took out any company info from this code, so if anyone can help me, I'd appreciate it.
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https:/google-link"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA account');
</script>
1) Get the 'GTAG' tracking code from Google Analytics (you've done that part).
2) Edit async in this line of code to async=""
From:
Code: Select all
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-xxxxxxxxx-x"></script>
Code: Select all
<script async="" src="https://www.googletagmanager.com/gtag/js?id=UA-xxxxxxxxx-x"></script>
Re: Google Tag Manager Code - Flare Error
Hi -
I am now trying use script from tag manager and trying to follow this thread. But it seems to be referencing only part of what I have been told to do. Has anybody had to use both of these bits of code?
My marketing department told me to put code generated by google tag manager into two places.
They told me to put this in the 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 ... efore(j,f);
})(window,document,'script','dataLayer','GTM-PCWMLJ2');</script>
<!-- End Google Tag Manager -->
They told me to put his in the body:
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-PCWMLJ2"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
I am now trying use script from tag manager and trying to follow this thread. But it seems to be referencing only part of what I have been told to do. Has anybody had to use both of these bits of code?
My marketing department told me to put code generated by google tag manager into two places.
They told me to put this in the 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 ... efore(j,f);
})(window,document,'script','dataLayer','GTM-PCWMLJ2');</script>
<!-- End Google Tag Manager -->
They told me to put his in the body:
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-PCWMLJ2"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
Re: Google Tag Manager Code - Flare Error
Following this--because I'm having the exact same issue I spoke with MadCap support and they said that it was due to Google Analytics not liking the equal sign highlighted in red above. We changed it to #61 instead, but still haven't received the data we are wanting (when people click a "thumbs up" or "thumbs down" button on a page).daphna wrote:Hi -
I am now trying use script from tag manager and trying to follow this thread. But it seems to be referencing only part of what I have been told to do. Has anybody had to use both of these bits of code?
My marketing department told me to put code generated by google tag manager into two places.
They told me to put this in the 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 ... efore(j,f);
})(window,document,'script','dataLayer','GTM-PCWMLJ2');</script>
<!-- End Google Tag Manager -->
They told me to put his in the body:
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-PCWMLJ2"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->