Advertisement

I want to insert JS for analytics after body tag

General questions relating to Joomla! 5.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
EuropeanMade
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Mon Mar 03, 2025 8:27 pm

I want to insert JS for analytics after body tag

Post by EuropeanMade » Sat Mar 15, 2025 2:49 pm

Hiya all,

My website is https://europeanmade.eu/ and I'm trying to get some analytics up and running. The code from seal metrics I'm trying to use is:

Code: Select all

<script>
/* SealMetrics Tracker Code */
(function() {
var options = {
   account: '67d58b254d01dc6d1226afb9',
   event: 'pageview',
   use_session: 1,
};
var url="//app.sealmetrics.com/tag/v2/tracker";function loadScript(callback){var script=document.createElement("script");script.src=url;script.async=true;script.onload=function(){if(typeof callback==="function"){callback();}};script.onerror=function(){console.error("Error loading script: "+url);};document.getElementsByTagName("head")[0].appendChild(script);}loadScript(function(){options.id=Math.floor((Math.random()*999)+1);if(window.sm){var instance=new window.sm(options);instance.track(options.event);}else{console.error("sm2 plugin is not available");}});
})();
/* End SealMetrics Tracker Code */
</script>
It says on the website: You must insert this javascript code in ALL your pages after <body> tag. I tried putting it in the Index file of the template but somehow it came out visible on my website :eek: (sorry I'm such a noob)

It also says on the website : Replace values with your own data; And I'm trying to figure out what they mean by that because I'm trying to embed their script?

Sorry if this is a bad question, I'm not very knowledgable. Thank you very much for your help in advance

Advertisement
User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 45098
Joined: Sat Apr 05, 2008 9:58 pm

Re: I want to insert JS for analytics after body tag

Post by Webdongle » Sat Mar 15, 2025 5:59 pm

Have you tried a custom module assigned to a non existent position?
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

EuropeanMade
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Mon Mar 03, 2025 8:27 pm

Re: I want to insert JS for analytics after body tag

Post by EuropeanMade » Sat Mar 15, 2025 6:40 pm

Webdongle wrote: Sat Mar 15, 2025 5:59 pm Have you tried a custom module assigned to a non existent position?
I haven´t,but I will definitely give it a try now and will let you know how it goes!

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 45098
Joined: Sat Apr 05, 2008 9:58 pm

Re: I want to insert JS for analytics after body tag

Post by Webdongle » Sat Mar 15, 2025 8:49 pm

You will need to configure your editor to allow js
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

EuropeanMade
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Mon Mar 03, 2025 8:27 pm

Re: I want to insert JS for analytics after body tag

Post by EuropeanMade » Sun Mar 16, 2025 3:31 pm

Webdongle wrote: Sat Mar 15, 2025 8:49 pm You will need to configure your editor to allow js
It's working but not in a hidden position (that is okay though for now!)

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 45098
Joined: Sat Apr 05, 2008 9:58 pm

Re: I want to insert JS for analytics after body tag

Post by Webdongle » Sun Mar 16, 2025 4:42 pm

If you type the name of a non existent Position (in the module edit screen) it should work and no be seen.
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

Advertisement

Post Reply

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