Inserting Analytics tracking code
In addition to simply inserting Google Analytics tracking code in your pages, sh404SEF has more options to help you deal with common situations:
Enable data collection
As seen on the Getting started page, there are currently 3 options to use Google Analytics:
- the regular Analytics called
version 4
orv4
: the default from 2021 Universal Analytics
: the standard up to 2021, still available for yearsGoogle Tag manager
.
Google Tag manager
Google Tag manager
is another option to enable Google Analytics data collection. As there are more and more javascript snippets or tags to be inserted in web site pages, it becomes harder to properly manage them, to be sure the correct IDs are inserted in the right pages, etc
Google Tag manager (amongst other so called Tags manager) can help solve this: instead of inserting your Universal analytics code, and maybe a Google AdSense tag, a DoubleClick tag and other similar tags, you can open an account with Google Tags manager. You get an ID for this account, and you must insert the Google Tags manager javascript code into your pages. But this will be the only one. You can then go to Google Tags manager web site and setup all your actual tags (Analytics, e-commerce, ads, etc) from there, within a single user interface.
sh404SEF can insert for you the Google Tag Manager
code, you only need to select this option in the Enable data collection
drop-down, and paste in your Google Tags manager ID in the corresponding field.
Analytics Custom code
You can enter here any analytics-specific code you need for more advanced uses. The code you enter will be added exactly as you enter it at the end of the Analytics snippet.
Custom code is only inserted when using either
v4
orUniversal Analytics
.
Universal Analytics Additional options
sh404SEF provides a few other options to improve your use of Google Analytics Universal. They do not apply to version 4 or to Google Tag Manager.
For both v4
and GTM
, there are options, but you can set them at your Google Analytics control panel.
Anonymize IP
Some countries legislation requires that analytics data be anonymized before being collected. Google provides an option for that, and enabling this setting will add the appropriate javascript to the tracking snippet to enable it.
Please be sure to check your locally applicable law to decide if you need this or not.
Enable Display features
The display features plugin is a Google Analytics plugin you can enable to gather additional data useful for accurate demographic analysis and enable advertising features in Google Analytics. When this option is enabled, sh404SEF will add the required code in your javascript snippet to activate it.
Enhanced link attribution
The enhanced link attribution plugin is another Google Analytics plugin which may improve the accuracy of click tracking on your pages. It is useful in case you have multiple links to the same URL on the same page as it allows differentiating clicks on each link, thus allowing you to fine-tune or improve your pages.
As per the documentation linked above, using the Enhanced link attribution plugin may require that you also make some changes to the links you want to track (they must have their own individual html id). The plugin must also be enabled in your Google Analytics account settings.
Snippet insertion options
Excluded IP
A common issue with Analytics is to get reliable data about your visitors, but only about your visitors. On some sites, visits from your company staff or other unwanted sources can become a bias. You can list here multiple IP address (IPV4) that should be excluded from Analytics. When a request comes from one of those IP addresses, sh404SEF will NOT include the Analytics snippet in the page, and they won't be counted at all.
Enable/disable for access levels and groups
Another option to exclude some visitors from the stats is to discount users from certain groups or for pages that require specific access levels. You can achieve this with sh404SEF using the Enable for access levels
, Enable for groups
and Disable for groups
select lists. This will allow you to discount from analytics traffic all Super users, for instance, or maybe support staff.
By default, the Enable for access levels
setting includes the Public
level. It means that all visitors will be accounted for. Be sure to check your site still has this access level (it should unless extreme customizatio was done during the site construction).
To avoid interfering with users groups attribution, we often create a specific group, called No-Analytics
, and we put all users that should not be included in Analytics stats in that group. You can also do the same with access levels.
Custom Analytics tracking code
If you need more control on the javascript snippet inserted in your page, you can take advantage of Joomla! JLayout overrides feature. As all Analytics tracking code are output to your pages using Joomla! JLayout, you can modify them by adding the required code inside your template folder, under the /your_template/html/layouts
directory. Please read the Joomla! JLayout documentation for more details.
The source layouts are located in:
/administrator/components/com_sh404sef/layouts/com_sh404sef/social
The JLayout path that you may want to override are the following ones:
com_sh404sef.analytics.snippet_ga4
com_sh404sef.analytics.snippet_uga
com_sh404sef.analytics.snippet_gtm