How to add the Google Analytics Code to Your Joomla! Website

Add Google Analytics to your Joomla! website

Google Analytics code makes it easier to track your visitor's behavior. In this blog, I will show you how you get it and add it to your Joomla! website.

What is the Google Analytics and why do you need to add it to your website?

Google Analytic allows you to:

  • Analyze data
  • Understand your site users to better evaluate the performance of your content, products, and more.

Before you can get Google Analytics code you need to have a Google account

Let’s get started with locating where you can find the Google Analytics code

1. Login to Google Analytics

2. Click Admin in the lower left corner

3. Choose the account dropdown and click create a new account

4. Choose the settings needed

GA new account

5. Copy the tracking code or ID

GA tracking ID

6. Add the code or tracking ID to your web page

Insert the Google Analytics code on your web page

Your code needs to be added inside your <HEAD></HEAD> tag on your website. There are several ways of adding it:

1. Add it in you template configurations

Pro:

Easy & fast if you have a template where there is a field to insert your code.

Con:

It might be difficult to know where in the template it will be inserted. And this code needs to be injected before the closing <head> tag.

If you have visitors from the EU this way is not compliant with the EU law that prohibits you from placing cookies on a device before the visitor has left his/her consent.

2. Insert it in your core files of your template

Pro:

No need to find (a better solution, or) an extension.

Con:

If you have visitors from the EU this way is not compliant with the EU law that prohibits you from placing cookies on a device before the visitor has left his/her consent.

If you have a template with an update service, you stand a chance that your code will be overwritten by the update. And you have to manually make sure that it is still there or you need to insert it again.

3. Install an extension and insert your code (you can find options at extensions.joomla.org)

Pro:

This solution may be more update safe and may offer more options of where to place the code.

Con:

If it is a commercial extension, you need to invest your money in it.

If you have visitors from the EU this way is not compliant with the EU law that prohibits you from placing cookies on a device before the visitor has left his/her consent.

4. Use our extension bundle including PixTracker, PixAnalytic and PixCookie Restrict

Find more information about PixTrackerPixAnalytic and PixCookie Restrict at the lab's page.

Pro:

If you have visitors from the EU, this is compliant with the EU law that prohibits you from placing cookies on a device before the visitor has left his/her consent.

Con:

You can do so much with this, and you won't know where to start ;) It's a commercial extension, so you need to invest your money in it.