How to add Google Analytics? Topic is solved

Discuss Search Engine Optimization in relation to Joomla! 4.x. This forum will also have discussions on SEF/SEO Joomla! 4.x extensions.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Post Reply
MAD King
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 192
Joined: Thu Aug 09, 2007 2:08 pm

How to add Google Analytics?

Post by MAD King » Tue Jul 05, 2022 4:23 pm

Hello,

normally, it goes into the index.php of I am not mistaken.
But when I create a child template the index.php cannot be copied.
I am afraid that when I add something to the index.php it will be overridden by future updates.

Anyone knows about that?

User avatar
sozzled
Joomla! Master
Joomla! Master
Posts: 12201
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: How to add Google Analytics?

Post by sozzled » Tue Jul 05, 2022 6:55 pm

As I wrote in reply to another question of yours:
sozzled wrote:
Tue Jul 05, 2022 12:54 am
... Do not modify original software ...
This includes making changes to the template's index.php file.

It's more practical to create a custom HTML module to add the required [Javascript] code and assign the module to one of the existing template's module positions and enable the module on the pages where you want to collect analytic information. Alternatively, if you're using a template that supports such a feature (Cassiopeia does not have a feature like this built in), it may be possible to add Javascript code "globally".

I use both approaches in my webcraft. 8)
“If you think I’m wrong then say, ‘I think you’re wrong.’ If you say ‘You’re wrong!’, how do you know?”
Walking the talk: https://j4xdemo.enduring.com.au
:)

MAD King
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 192
Joined: Thu Aug 09, 2007 2:08 pm

Re: How to add Google Analytics?

Post by MAD King » Tue Jul 05, 2022 7:14 pm

I have never thought of doing it into a module.
That is fantastique. I am using Cassiopeia, because I think this is also a very good and fast template with a lot possibilities if you are familiar with it. Will take some time.

Thank you.

MAD King
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 192
Joined: Thu Aug 09, 2007 2:08 pm

Re: How to add Google Analytics?

Post by MAD King » Tue Jul 05, 2022 7:24 pm

How do I assign a module to the <head> position? Google requires one code to be placed between the <head> area.

User avatar
sozzled
Joomla! Master
Joomla! Master
Posts: 12201
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: How to add Google Analytics?

Post by sozzled » Tue Jul 05, 2022 7:43 pm

You don't necessarily have to assign the module to the <head> section (even if that's what Google "recommends"). Try assigning the module to any position and see if Google Analytics—I assume that's what we're discussing—starts collecting data. Works for me. :)
Last edited by sozzled on Tue Jul 05, 2022 9:26 pm, edited 1 time in total.
“If you think I’m wrong then say, ‘I think you’re wrong.’ If you say ‘You’re wrong!’, how do you know?”
Walking the talk: https://j4xdemo.enduring.com.au
:)

User avatar
AMurray
Joomla! Exemplar
Joomla! Exemplar
Posts: 7817
Joined: Sat Feb 13, 2010 7:35 am
Location: Australia

Re: How to add Google Analytics?

Post by AMurray » Tue Jul 05, 2022 9:23 pm

Google says put the code in the <head> section of the HTML, not the "head module position". Two different things...... ?

Regardless, using the custom module makes sense.
Regards - A Murray

MAD King
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 192
Joined: Thu Aug 09, 2007 2:08 pm

Re: How to add Google Analytics?

Post by MAD King » Wed Jul 06, 2022 1:48 pm

So, I added the code into two modules, and after waiting overnight it is not working.

User avatar
sozzled
Joomla! Master
Joomla! Master
Posts: 12201
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: How to add Google Analytics?

Post by sozzled » Wed Jul 06, 2022 7:42 pm

Try something simpler: one module (not two). What is the [Javascript] code you're using to feed your site visits into Google Analytics?
“If you think I’m wrong then say, ‘I think you’re wrong.’ If you say ‘You’re wrong!’, how do you know?”
Walking the talk: https://j4xdemo.enduring.com.au
:)

MAD King
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 192
Joined: Thu Aug 09, 2007 2:08 pm

Re: How to add Google Analytics?

Post by MAD King » Wed Jul 06, 2022 7:43 pm


User avatar
sozzled
Joomla! Master
Joomla! Master
Posts: 12201
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: How to add Google Analytics?

Post by sozzled » Wed Jul 06, 2022 7:52 pm

I don't know anything about this plugin. Does it work?
“If you think I’m wrong then say, ‘I think you’re wrong.’ If you say ‘You’re wrong!’, how do you know?”
Walking the talk: https://j4xdemo.enduring.com.au
:)

MAD King
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 192
Joined: Thu Aug 09, 2007 2:08 pm

Re: How to add Google Analytics?

Post by MAD King » Wed Jul 06, 2022 8:00 pm

Looks like. Let you know in a while. Got that from the German Joomla.de site forum.

User avatar
sozzled
Joomla! Master
Joomla! Master
Posts: 12201
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia

Re: How to add Google Analytics?

Post by sozzled » Wed Jul 06, 2022 8:01 pm

Good for you. 8)
“If you think I’m wrong then say, ‘I think you’re wrong.’ If you say ‘You’re wrong!’, how do you know?”
Walking the talk: https://j4xdemo.enduring.com.au
:)

MAD King
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 192
Joined: Thu Aug 09, 2007 2:08 pm

Re: How to add Google Analytics?

Post by MAD King » Wed Jul 06, 2022 8:59 pm

sozzled wrote:
Wed Jul 06, 2022 8:01 pm
Good for you. 8)
Yes :D

juliana9089
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Tue Jul 12, 2022 9:25 pm

Re: How to add Google Analytics?

Post by juliana9089 » Tue Jul 12, 2022 9:30 pm

1. Login to Joomla Admin Panel. 2. On the left side menu, go to Extensions → Extension Manager. 3. Click Browse button and select the zip file containing the plugin. 4. Click Upload & Install and then click Install Now. 5. Click Go to extension and click Google Analytics. 6. Copy the script and paste it into the <head> tag at the beginning of your website’s HTML. 7. Click Save Config.

MAD King
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 192
Joined: Thu Aug 09, 2007 2:08 pm

Re: How to add Google Analytics?

Post by MAD King » Tue Jul 12, 2022 9:43 pm

juliana9089 wrote:
Tue Jul 12, 2022 9:30 pm
1. Login to Joomla Admin Panel. 2. On the left side menu, go to Extensions → Extension Manager. 3. Click Browse button and select the zip file containing the plugin. 4. Click Upload & Install and then click Install Now. 5. Click Go to extension and click Google Analytics. 6. Copy the script and paste it into the <head> tag at the beginning of your website’s HTML. 7. Click Save Config.
:laugh: :laugh: :laugh: :) :D Very funny.


Post Reply

Return to “Search Engine Optimization (Joomla! SEO) in Joomla! 4.x”