Joomla 4 - Google Analytics Adding Tag Mr Script Topic is solved

General questions relating to Joomla! 4.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Post Reply
User avatar
Duckdown
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 136
Joined: Sat Jun 25, 2016 7:00 am

Joomla 4 - Google Analytics Adding Tag Mr Script

Post by Duckdown » Sat Sep 09, 2023 6:42 am

I have got the script for Google Tag Manager but can't find where to copy it and my brain needs a few more specifics than what I have seen
From what I have found so far I have tried:
1. Dashboard 2. System 3. Manage Extensions 4. Templates (Locked) If this is the right place Do I unlock?
also:
1. Dashboard 2. System 3. Site Templates 4.Cassiopeia Details and Files (Also looked at Options)

I recall some years ago finding HTML coding in Joomla 3 and presume that is what I am trying to find now?
In particular index.php. I am not sure how I get this script into there and all my pages.
I think someone mention creating an HTML module.
Another script is supplied during creating Tag Mr acvcount that goes after opening <body> . I am not sure that has to go on every page?

User avatar
Duckdown
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 136
Joined: Sat Jun 25, 2016 7:00 am

Re: Joomla 4 - Google Analytics Adding Tag Mr Script

Post by Duckdown » Sat Sep 09, 2023 6:55 am

Okay a bit more search and I found index.php
1. Dashboard 2. System 3. Site Templates 4, Cassiopeia Details & Files 5. Index.php
I selected index.php and at line 116 was <header>
Here are the lines 114 to 116 <head>
<!DOCTYPE html>
<html lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
<head>
(Should I include the script here or:
<jdoc:include type="metas" />
<jdoc:include type="styles" />
<jdoc:include type="scripts" />
HERE???????
</head>
Does this do it for every page?
The other noscript should it go directly under line 122 which is
<body class="site <?php echo $option

helpwithjoomla
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 146
Joined: Sat Sep 21, 2019 7:29 pm
Contact:

Re: Joomla 4 - Google Analytics Adding Tag Mr Script

Post by helpwithjoomla » Sat Sep 09, 2023 4:15 pm

Put the tag manager script as close to the opening <head> tag as possible, but below any dataLayer declarations.

Adding it to the template index file will mean that it is added for every page.
Joomla Developers Available To Help With Joomla!
https://www.helpwithjoomla.com

User avatar
Duckdown
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 136
Joined: Sat Jun 25, 2016 7:00 am

Re: Joomla 4 - Google Analytics Adding Tag Mr Script

Post by Duckdown » Sat Sep 09, 2023 7:29 pm

helpwithjoomla: What will happen to it when I do an update to Joomla?

gws
Joomla! Champion
Joomla! Champion
Posts: 5620
Joined: Tue Aug 23, 2005 1:56 pm
Location: South coast, UK
Contact:

Re: Joomla 4 - Google Analytics Adding Tag Mr Script

Post by gws » Sat Sep 09, 2023 9:02 pm

It will be overwritten. Create a child template then it will not be overwritten on updates.

User avatar
Duckdown
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 136
Joined: Sat Jun 25, 2016 7:00 am

Re: Joomla 4 - Google Analytics Adding Tag Mr Script

Post by Duckdown » Sun Sep 10, 2023 2:38 am

Thanks gws. That is another aspect I will have to explore.

helpwithjoomla
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 146
Joined: Sat Sep 21, 2019 7:29 pm
Contact:

Re: Joomla 4 - Google Analytics Adding Tag Mr Script

Post by helpwithjoomla » Sun Sep 10, 2023 3:56 pm

Here's a link for creating a Child template with J4: https://docs.joomla.org/J4.x:Child_Templates
Joomla Developers Available To Help With Joomla!
https://www.helpwithjoomla.com

User avatar
Nidzo2203
Joomla! Explorer
Joomla! Explorer
Posts: 303
Joined: Sat Nov 21, 2009 4:52 pm
Contact:

Re: Joomla 4 - Google Analytics Adding Tag Mr Script

Post by Nidzo2203 » Sun Sep 10, 2023 7:15 pm

Install this plugin https://extensions.joomla.org/extension/phoca-site/
and put your G4 analytics code in header.
Don't complicate.

User avatar
Duckdown
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 136
Joined: Sat Jun 25, 2016 7:00 am

Re: Joomla 4 - Google Analytics Adding Tag Mr Script

Post by Duckdown » Sun Sep 10, 2023 7:22 pm

Nidzo2023: Tnx I shall look at that, but I think I still have the problem of updates to Joomla?

User avatar
Duckdown
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 136
Joined: Sat Jun 25, 2016 7:00 am

Re: Joomla 4 - Google Analytics Adding Tag Mr Script

Post by Duckdown » Fri Sep 22, 2023 7:50 pm

After considering all the suggestions here and lots more research, I came across a very helpful individual that guided me through the process below. It is also a steep learning curve to navigate my way around the Google Analytics site and understand what it presents. At this stage I don't need much information. Just how many visits and where they are coming from. They suggested it might be up to 48 hours before I see anything but here we are about 10 hours later and it indicates 1 visitor, from China. Mmmmm. Anyway here is what I did in my backend after signing up to Google analytics and getting script.
1. Created Module named Goggle Analytics
2. Copied script provided by Google into Code (not Editor) of the module. I use JC Editor
3. Assigned page position “Top-Bar” Cassiopeia
4. Save Module
5. Components>JC Editor>Profiles>Default>Editor Parameters>Advanced.
6. Under Code Blocks: Enable Yes Allow Script Yes Allow CSS Yes (didn't touch anything below these)
7. In modules move the Google Analytics module above the Banner Image
(position top-bar)

NB: Have I missed anything? Was there something I changed in Global Config? I make scribble notes and then enter all these things into a document for future references.
Someone might assess this for others to consider.

jovanddd
Joomla! Apprentice
Joomla! Apprentice
Posts: 25
Joined: Sat Apr 09, 2022 2:38 pm
Location: Beograd
Contact:

Re: Joomla 4 - Google Analytics Adding Tag Mr Script

Post by jovanddd » Sun Sep 24, 2023 12:05 pm

google analytics or google tag manager script at the end?

User avatar
Duckdown
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 136
Joined: Sat Jun 25, 2016 7:00 am

Re: Joomla 4 - Google Analytics Adding Tag Mr Script

Post by Duckdown » Sun Sep 24, 2023 8:30 pm

jovanddd I am not sure how to answer your question but suggest this link may be worth having a read of. Probably clarifies better the steps I took (see above).
https://www.kuneze.com/blog/126-how-to- ... extensions.
During all this research I found my host already provides the facility to analyse. I guess it is worth having the two to compare.


Post Reply

Return to “General Questions/New to Joomla! 4.x”