Google Tag Manager

Permalink 1 user found helpful
What is the best way to add Google Tag Manager to a concrete5 web site?

 
mnakalay replied on at Permalink Reply
mnakalay
Hello,

The easiest way to add the Tag Manager Snippet is to add it through through the dashboard's tracking codes page which you can find under System & Settings > SEO & Statistics > Tracking codes. The path in the URL would be dashboard/system/seo/codes
PhobosTech replied on at Permalink Reply
PhobosTech
Dude - really? You're obviously not familiar with GTM - part of the GTM snippet needs to be plugged in immediately following the <body> tag. What you just told this person (2 years ago now?) is exactly why they posted this question. There is no place to properly enter GTM tags.
mnakalay replied on at Permalink Best Answer Reply
mnakalay
Hi there,

with all the respect due to your obviously wide experience in GTM, Concrete5, and this community, I have to disagree.

Your post contains 3 statements 1 of which is overreaching and 2 are misinformed.

First, you claim you know exactly why they posted their question. That's overreaching.

I have answered hundreds of questions here from the most basic to some very technical. In my experience, some users here really do not have the know how to deal with technical stuff as you pointed it out yourself in another posthttps://www.concrete5.org/community/forums/usage/google-tracking-cod...

Your first misinformed statement is I am not familiar with GTM and the second one is there is no place to properly enter GTM tags.

Given your other messages on the topic, I am happy to help you figure it out.

As you said, part of the GTM snippet needs to be plugged immediately following the body tag. One problem though: it is in no way a need or a requirement.

The first GTM snippet is extremely important and should be put in the head. For that one, my initial answer is absolutely correct.

The second snippet is used for those users who have JavaScript disabled in their browsers. Most data online suggest that's about 2% of the total.

So if you feel you absolutely must have the whole 100% and you must absolutely have that 2 % as well then yes, you will need the second snippet which is pure HTML.

Putting it right after the opening <body> tag is a 2 parts proposition. Should it be at the top of the page instead of the bottom and does it really have to be at the absolute top?

For the first one I would say yes, it is probably better to have it at the top instead of near the bottom so recording happens early on.

Does it need to be immediately following the opening <body> tag? Absolutely not. In a browser where JavaScript is disabled, a few lines down the page won't make a difference unless you put your snippet right after a really heavy image (which would be stupid I give you that)

Now, having introduced the idea that the snippet is not strictly necessary and that it doesn't have to be absolutely right after the opening <body> tag, let's see what our options are.

The first and easiest would be to simply add the snippet to an HTML block and add it to a top global area that exists in every page type.
That requires no technical skills. The snippet might not be immediately following the body tag but close enough. Most themes in the marketplace use global areas for their nav bars, logos, headers and stuff like that so it should not be an issue.

A second way, slightly more involved and which I understand you don't favor as being too technical for some, is to modify your theme files to hard-code that snippet directly. Of course, if that is a theme which you intend on updating from time to time from the marketplace, it is a problem as you will lose your modifications.

A final way which would allow you to put the snippet exactly where you want it without modifying your theme is to use page events. That is, however, technically even more complex than the previous solution.

You can hook onto the on_page_output event which allows you to grab the whole page content before it is displayed in the browser. You are then given the possibility to modify that content before sending it back to be displayed. With a little regex, you can add your snippet exactly where you want it.
byvictoria replied on at Permalink Reply
byvictoria
Beautiful, thank you so much....