Support Forum

  • Page:
  • 1

How to get code above body tag

zentoolsIf you use Zentools please post a review at the Joomla! Extensions Directory.

Hi Jason,

If ya still around and burning the midnight oil, I have been wracking my brain trying to work out how to:

Using a module called mod_connectanalytics I need the module to place a block of code immediately before the </body> tag.

craig-james.com.au

I have set the module in the top left however it is being inserted in the source code below </body> tag and the tracking code is not being recognised.

If it is simple to do could you give me a pointer on how to do otherwise its OK I will worry about it another time. Just learning about SEO and there is no forum to help me out at all.

Cheers
Craig ;)
  • Craig's Avatar
  • Craig
  • 12 Month Developer
  • 2G rocks
  • 418 posts
  • Karma: 17
The administrator has disabled public write access.
Hey Craig,

Sure thing. The doe can probably be injected directly in the index file but I guess the module would want to work more gracefully. Do you have a link for where this module comes from. I couldn't quite find any code on your site.
I think these sort of modules normally need to be published to the debug position.
Give that a try and let me know. Should be around another couple of hours to help.

Cheers
Jason.
  • Jason D's Avatar
  • Jason D
  • 6 Month Developer
  • 2957 posts
  • 12 Thanks
  • Karma: 75
The administrator has disabled public write access.
Hi Jason,

That got the sucker...Thanks

Der Der Debug is that what its for ;)

Have a good night...morning :laugh:

Chhers
Craig ;)
  • Craig's Avatar
  • Craig
  • 12 Month Developer
  • 2G rocks
  • 418 posts
  • Karma: 17
The administrator has disabled public write access.
Nice work.

Yeah never used the position myself and once I sent the post off I remember that there is an analytics position as well I think :) Well if Grid 1-28 are not good enough then go debug!

Have a good night Craig. I'll be counting sheep at sunrise :P

Cheers,
Jason.
  • Jason D's Avatar
  • Jason D
  • 6 Month Developer
  • 2957 posts
  • 12 Thanks
  • Karma: 75
The administrator has disabled public write access.
Hi Guys,

Just woke up with a clear head...its amazing what sleep does ;)

The code is sitting where it is supposed to however can see that the module is not writing the tracker code correctly (leaving off the "" either side of tracker)

so I will uninstall the module and try to do this manually.

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-xxxxxxxx-x");
pageTracker._trackPageview();
} catch(err) {}</script>

How would one insert manually the tracking code "UA-xxxxxxxx-x" into index.php so as it is loaded just before the /body tag on each page?

Info given by Google >> Database driven sites - Insert the tracking code on your index.php page or equivalent (eg. default.php, index.cfm).

Any guidance or pointers will be counted as GOD like ;)

Cheers
SEO Mad Craig ;)
  • Craig's Avatar
  • Craig
  • 12 Month Developer
  • 2G rocks
  • 418 posts
  • Karma: 17
The administrator has disabled public write access.
Hey Craig - I think the best thing to do is either add the code to a custom html module with the wysiwyg editor off and then publish to the analytics position. Or just open the index.php file of the template and then paste the code directly into the template.

Hope that helps.

Anthony
  • Anthony Olsen's Avatar
  • Anthony Olsen
  • LIfetime Developer - Big Bamboo
  • 23925 posts
  • 788 Thanks
  • Karma: 433
The administrator has disabled public write access.
Hi Anthony,

Yeh wasnt sure what index.php they were describing thats why I thought I would run it by ya

However creating a custom module with editor turned off is more logical and cleaner solution

Thankyou very muchly;) all done, itz all good!
  • Craig's Avatar
  • Craig
  • 12 Month Developer
  • 2G rocks
  • 418 posts
  • Karma: 17
The administrator has disabled public write access.
Hi Guys

Trying this out (custom module in the analytics position)

Any idea how you stop the Joomla editor putting <p></p> around the code? Craig I noticed you'd managed to do this on your site.

Cheers
Martin
  • Martin's Avatar
  • Martin
  • 12 Month basic
  • 76 posts
  • Karma: 0
The administrator has disabled public write access.
Hi MArtin,

I think you will need to add the code with the wysiwyg editor turned off. Its a pain but I think thats the safest way.

Cheers Anthony
  • Anthony Olsen's Avatar
  • Anthony Olsen
  • LIfetime Developer - Big Bamboo
  • 23925 posts
  • 788 Thanks
  • Karma: 433
The administrator has disabled public write access.
Hi Guys,

Yep turning off whatever editor you are using did the trick in both globals and user

Cheers
Craig
  • Craig's Avatar
  • Craig
  • 12 Month Developer
  • 2G rocks
  • 418 posts
  • Karma: 17
The administrator has disabled public write access.
Thanks Both

Yep did that. Turned off the editor in User and Global config. Edited the analytics code to remove the <p></p>, saved and then switched the editor back on to continue with site.

Worked a treat.

Thanks for your help.

Cheers
  • Martin's Avatar
  • Martin
  • 12 Month basic
  • 76 posts
  • Karma: 0
The administrator has disabled public write access.
Hi Martin,

Jason initially helped me out on that one, without both Anthony and Jason I would be stuffed! ;)

Glad its doin its job, I found analytics to be the beez neez, one hell of a program

Good Luck
Craig
  • Craig's Avatar
  • Craig
  • 12 Month Developer
  • 2G rocks
  • 418 posts
  • Karma: 17
The administrator has disabled public write access.

zentoolsIf you use Zentools please post a review at the Joomla! Extensions Directory.

Happy Campers