Build hangs with Google Analytics code in master page

This forum is for all Flare issues related to the HTML5, WebHelp, WebHelp Plus, and Adobe Air Targets
Post Reply
minicyclist
Propeller Head
Posts: 60
Joined: Wed Apr 09, 2014 3:51 pm

Build hangs with Google Analytics code in master page

Post by minicyclist »

Hello,

Some of our larger projects are failing to build after we've added Google Analytics code to the topic master page - the build hangs at 'Resolving links in output files...'. Strangely, this only happens in larger (a few hundred topics) projects.

The code we've added is as follows (with the actual GA ID hidden):

Code: Select all

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

			gtag('config', 'UA-XXXXXXX-XX');
		</script>
This is at the start of the <head> section in the master page.

I've tried moving the code around in the master page to no avail. The log doesn't give any clues. The fact that this works in smaller projects is leaving me mystified.

Grateful for advice.
roboHAL
Sr. Propeller Head
Posts: 254
Joined: Mon Dec 31, 2012 9:57 am

Re: Build hangs with Google Analytics code in master page

Post by roboHAL »

Hi minicyclist.

I'm unable to tell you why your code is causing your build to hang. However, I can tell you I too am using google analytics in my master page, have over one thousand topics, and my builds do not "hang" or otherwise have any abnormalities.

The script code I've inserted is as follows, and needs to go within the head tag:

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-########-##', 'auto');
ga('send', 'pageview');

</script>


Hope that helps. :)
NorthEast
Master Propellus Maximus
Posts: 6359
Joined: Mon Mar 05, 2007 8:33 am

Re: Build hangs with Google Analytics code in master page

Post by NorthEast »

minicyclist wrote:I've tried moving the code around in the master page to no avail. The log doesn't give any clues. The fact that this works in smaller projects is leaving me mystifie
I use this same code, although I use it in a snippet, and I put it at the end of the body section of my master page, rather than in the head.

Works fine for me in all projects, including large projects (1500+ topics).

If you're having problems with only certain projects, then I'd check that something else isn't causing the problem.

roboHAL wrote:The script code I've inserted is as follows, and needs to go within the head tag:
That's the old 'ga' code for analytics.
It was replaced last year with the 'gtag' code, which minicyclist is using.
roboHAL
Sr. Propeller Head
Posts: 254
Joined: Mon Dec 31, 2012 9:57 am

Re: Build hangs with Google Analytics code in master page

Post by roboHAL »

Dave Lee wrote: That's the old 'ga' code for analytics.
It was replaced last year with the 'gtag' code, which minicyclist is using.
Hi David. Thank you. I'll preface my reply by stating that I am not a JAVA script coder. The code I wrote herein this thread was provided to me - perhaps a little over a year ago - by my development staff.

Here is something I do know. It works! Meaning, statistics are being captured, and I have reason to believe the data is accurate.

So please allow me to ask you the following questions.

(1) In your opinion (or fact), is there an advantage to use the "other" more current gtag code, and if so, what is the advantage?

(2) In your opinion (or fact), is there a disadvantage to use the "other" more current code, with respect to the code I'm currently using?

Thank you, David. :)
NorthEast
Master Propellus Maximus
Posts: 6359
Joined: Mon Mar 05, 2007 8:33 am

Re: Build hangs with Google Analytics code in master page

Post by NorthEast »

roboHAL wrote:Hi David. Thank you. I'll preface my reply by stating that I am not a JAVA script coder. The code I wrote herein this thread was provided to me - perhaps a little over a year ago - by my development staff.

Here is something I do know. It works! Meaning, statistics are being captured, and I have reason to believe the data is accurate.
The code you've got would be copied and pasted from the Google Analytics site; it's generated for you when you view your 'tracking code'.

Google Analytics changed the tracking code format in around August 2017, from the old 'ga' format (like yours) to the new 'gtag' format (like minicyclist's).
So if you get your tracking code right now, it'll give you the 'gtag' code.

The old 'ga' code will still work fine now, and likely for a number of years, but going forward you want to be using 'gtag'.
roboHAL
Sr. Propeller Head
Posts: 254
Joined: Mon Dec 31, 2012 9:57 am

Re: Build hangs with Google Analytics code in master page

Post by roboHAL »

Dave Lee wrote:The old 'ga' code will still work fine now, and likely for a number of years, but going forward you want to be using 'gtag'.
Thank you, David.
minicyclist
Propeller Head
Posts: 60
Joined: Wed Apr 09, 2014 3:51 pm

Re: Build hangs with Google Analytics code in master page

Post by minicyclist »

Thanks all.

Yes, I'd prefer to use the new code.

Thanks for recommendations Dave. Sadly it still won't work for us. It seems to be this line that's causing the problem:

Code: Select all

<script async="1" src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXX-XX">
        </script>
Given the lack of diagnostics it's hard to know what might be causing it. It may be that we have to revert to the old code but I'll flag it with Madcap.
NorthEast
Master Propellus Maximus
Posts: 6359
Joined: Mon Mar 05, 2007 8:33 am

Re: Build hangs with Google Analytics code in master page

Post by NorthEast »

minicyclist wrote:Thanks for recommendations Dave. Sadly it still won't work for us. It seems to be this line that's causing the problem:

Code: Select all

<script async="1" src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXX-XX">
        </script>
Given the lack of diagnostics it's hard to know what might be causing it. It may be that we have to revert to the old code but I'll flag it with Madcap.
I insert the whole code in my master page (actually in a snippet), after the body proxy, and before the end of the closing body tag.

I also have async="" rather than async="1". Not sure if that makes a difference.

Code: Select all

<script async="" src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXX-XX">
        </script>
minicyclist
Propeller Head
Posts: 60
Joined: Wed Apr 09, 2014 3:51 pm

Re: Build hangs with Google Analytics code in master page

Post by minicyclist »

Thanks Dave. Yes, tried your suggestions but no luck. I have found out what is causing it though - I copied a target from a working project and it turned out that it was the 'Use lowercase filenames' option that was stalling the build. With this option unchecked, it builds fine. Now to find out why!
agracer
Propeller Head
Posts: 23
Joined: Fri Aug 19, 2016 11:58 am

Re: Build hangs with Google Analytics code in master page

Post by agracer »

@minicyclist
I'm so glad I found your post. My build was hanging with the GA as well, and this hack did the trick!
asbahr+
Propeller Head
Posts: 18
Joined: Tue Sep 29, 2015 4:54 am

Re: Build hangs with Google Analytics code in master page

Post by asbahr+ »

I have to check the "Use lowercase file names" option or many external links to help will break.

I tried putting the code in a snippet and that didn't work. My build hangs at Resolving links in output files....

Does anyone else have any other tips?

Thanks!
minicyclist
Propeller Head
Posts: 60
Joined: Wed Apr 09, 2014 3:51 pm

Re: Build hangs with Google Analytics code in master page

Post by minicyclist »

I never worked out a solution. I'd log a bug with Madcap.
Post Reply