Best location for Google Analytics tag? Considering GA 4?

This forum is for all Flare issues related to the HTML5, WebHelp, WebHelp Plus, and Adobe Air Targets
Post Reply
Curlyshell
Propeller Head
Posts: 65
Joined: Fri Mar 01, 2019 9:14 am

Best location for Google Analytics tag? Considering GA 4?

Post by Curlyshell »

Is it better to have the Google Analytics tag in the <head> or <body>?

I'm asking because putting it in the Master Page is so very convenient (and much cleaner), but places the tag into the body.

I've seen posts from power users who say using the Master Page is just fine. Will it still be fine with Google Analytics 4?
"I'm a technical writer, not a developer," she said...
NorthEast
Master Propellus Maximus
Posts: 6363
Joined: Mon Mar 05, 2007 8:33 am

Re: Best location for Google Analytics tag? Considering GA 4

Post by NorthEast »

I put the analytics code in the body of the master page, just before the closing </body> tag.

I also include it as a snippet, so I can re-use it in multiple master pages. And you can't use snippets in the head.

Google will suggest putting it in the head, but the only reason they say that is to ensure that the script runs early, in case someone leaves the page before it has fully loaded and runs the script.
But the analytics script works just fine in the body, it just runs a bit later than it would in the head.
Post Reply