Robert
Robert

Reputation: 530

How can I install the Google Tag Manager (GTM) on Content Management System (CMS) MotoCMS?

For Google Tag Manger Google says to place their JavaScript code snippet, "as close to the opening <head> tag as possible on every page of your website, replacing GTM-XXXX with your container ID. (https://developers.google.com/tag-manager/quickstart)

And then for the nonsript snippet they say to place it "immediately after the opening <body> tag on every page of your website, replacing GTM-XXXX with your container ID (https://developers.google.com/tag-manager/quickstart)

However, I'm using the CMS MotoCMS and within their code injection sections, My only choice within their CMS is Header injected into the <head> tag on every page of my site.

And the Footer injected before </body> tag on every page of my site.

Would putting Javascript into the Header and the nonscript in the Footer cause any errors or problems?

If the answer is yes, would anyone know of how to implement the code within the CPanel file manager side of my hosting provider?

For example, can I save the code and upload it as a separate file within the CPanel of my hosting and where relative to my public_html?

I'm scared of editing my code mainly becasue of the following message when I attempt to edit any file within my hosting providers CPanel File manager:

"Back up the original file before converting character sets, since this action can produce unexpected results. If encodings are not important to you because you will only be working with English or other Western languages, you can disable this dialog by clicking here: Disable Encoding"

Which character encoding should I use when opening my file (utf-8, etc) if I need to implement the code within the CPanel file manager side of my hosting provider?

In other words, How can I install the Google Tag Manager (GTM) on Content Management System (CMS) MotoCMS?

CLARIFICATION: Unfortunately, my CMS MotoCMS, in the header, the code is placed BEFORE the closing </head> tag NOT as high as the <head> as possible. In the footer is placed BEFORE the closing </body> tag on every page of my site, NOT immediately after the the opening <body>. Would the coding discrepancy cause any issue?

Upvotes: 1

Views: 1015

Answers (1)

Kellen
Kellen

Reputation: 1032

GTM is regularly implemented in the <head>. In fact, here are the instructions from tagmanager.google.com: enter image description here

Out of around 10 implementations, I've only experienced one error twice. In both scenarios, other developers have moved page scripts to the bottom of the page. It makes sense for performance reasons, but unfortunately, Drupal (the CMS I use) bundles the all scripts. This caused JQuery to be declared in the body. If you're using JQuery in your GTM tags, declaring JQuery in the body will cause them to fire inconsistently. I wouldn't think this would be an issue for you!

Use UTF-8!

Also, if you regularly do web development, I'd look into using versioning control, such as git. If you're concerned about screwing up something in code, version control will allow you to revert changes. Also, setting up a development environment is also wise, so you can test things without messing with the production site.

Hope this helps!

Upvotes: 1

Related Questions