View Full Version : Solved How to insert codes (analytics, meta tags)?
angelcbs
01-21-2011, 01:27 AM
I need to insert google publisher tags between <head> tags and also the google analytics code. How do I do that? I cannot find any <body> tags either, only xml.
Hi,
Generally, you don't have to change any core files. Here a quick how to:
* Create a new custom HTML module and paste inside the Google Analitics code
Remember: use the HTML button to open the HTML editor, or your code will be parsed as text.
* Publish your custom module in the debug position, don't worry if the Joomla! debug is not enabled, your Google Analytics code will be parsed as it should be.
* Check your front-end source code at the bottom, you will see the Google Analytics code.
* Please tell us if this helps, so we can update the wiki for this guide.
Regards,
Danny
angelcbs
01-21-2011, 05:30 PM
Well, I tried that, but the code kept showing at the front page. I had to snoop around the plugin code and found the in the /base-theme/blocks the head.php, and inserted in there. Worked like a charm.
Thanks anyway.
splico123
01-22-2011, 12:56 AM
Well, I tried that, but the code kept showing at the front page. I had to snoop around the plugin code and found the in the /base-theme/blocks the head.php, and inserted in there. Worked like a charm.
Thanks anyway.
That might be true mate only watch out with updates of template since you will allways have to remember to re-apply it there so the above sollution with a module would be better until JA decides to hopefully include it in templates as default.
phill luckhurst
01-22-2011, 04:47 AM
Why would JA want to include analytics code as a default in templates? The previous suggestion of simply creating a module in the debug position containing all your meta tags etc is an excellent way to do this especially for those who do not like digging around in code. If you can create a module (If you cannot then you should not be running a website) then you can add analytics code. It cannot be simpler really.
I'll go through the steps for those that do not know
Go into module manager and creat a custom HTML module.
Set that module to postion Debug
Set it to display on all pages
Click the "Toggle editoer" button to make sure you are in an html only view on your editor.
Type in your custom code eg
<meta>.....your analytics code.....</meta>
Set display title to no then publish your module
Now go to your website and using "View Source" from your browser check you can see your meta tags.
angelcbs
01-22-2011, 05:00 AM
Well, analytics nowaday is supposed be inserted BEFORE </head> tag and NO LONGER before the </body> tag - so using the debug module would be incorrect.
codger
01-23-2011, 10:17 PM
See also, this thread (http://www.joomlart.com/forums/showthread.php?50743-Placing-Analytics-Code-in-JAT3v2).
Saguaros
01-31-2011, 09:43 AM
you should use extension from here http://extensions.joomla.org/search?q=google+analytics
and put it at the footnav position, instead of hard coding in the php files.
Thanks
mikac
02-01-2011, 04:34 AM
Hello Tienhc,
Which extension is Joomla! 1.6? None, I think.
Please tell me it's different, because this is T3 2.0 Joomla 1.6 thread.
And if someone can confirm that Danny's (and Phill's) solution is the right one!
Thank you!
phill luckhurst
02-01-2011, 04:58 AM
A suitable extension for 1.6 - http://extensions.joomla.org/extensions/site-management/site-traffic-statistics/9940?qh=YTozOntpOjA7czo5OiJhbmFseXRpY3MiO2k6MTtzOj g6ImFuYWx5dGljIjtpOjI7czoxMDoiYW5hbHl0aWNzJyI7fQ%3 D%3D
mikac
02-01-2011, 07:47 PM
Thank's I really appreciate your help
Is it tested, have you tried it already? This is Analytics Suite, but I guess we could just install the plugin...
Or.. Maybe we should just make a module in Debug position and insert Google code directly...like suggested earlier?
Anyway, thank you very much.
codger
02-01-2011, 08:49 PM
Few of us would want the suite, but the plugin might be an answer.
Unfortunately, the custom mod in the Debug position seems not to work in JAT3 2.0 for J!1.6 - see link in #7 above.:((
mikac
02-01-2011, 09:15 PM
Oh right. I'm sorry. We are stuck...
phill luckhurst
02-01-2011, 10:03 PM
Why are you stuck?
Does the suite not do the job for you? I have only briefly tested just to see if it puts the code in the right place (which it does). I do not use analytics this way. I do it server side as I have my own servers.
Give me a while and I will try some additional options.
phill luckhurst
02-01-2011, 10:07 PM
Unfortunately, the custom mod in the Debug position seems not to work in JAT3 2.0 for J!1.6 - see link in #7 above.:((
It does work, I have tested it. For it to work you must switch off the editor in Global Config, not in the manager itself or Tiny still does the nasty deed. So go to global config and select "No Editor" as your default then try again.
codger
02-01-2011, 11:07 PM
It does work, I have tested it.
What did you actually test, Phill?
I was so convinced that you were going to be right with this - I was so disappointed to find that although the body of the analytics code stayed put, the tags were stripped off. :((
phill luckhurst
02-01-2011, 11:25 PM
I shall test again on my localhost but when I was viewing the source code yesterday when I tried this the tags were there.
phill luckhurst
02-02-2011, 03:07 AM
OK, the problem is a simple one and many seem to be falling foul of it. It is one of filters. A new feature of Joomla 1.6 is the filters option, a part of the new ACL.
In the filters you can select code that automatically will get stripped out no matter what editor you use including the no editor option. On my test site I had already set these options but it didn't twig at first that everyone would have done this.
Go to your article manager and take a look at the options button in the top right corner of you screen (It looks like a double light switch. In the popup window you will see the following image. Click on the text filters tab and adjust the settings for Administrator and Super Users to "No Filtering". Save and close your aettings and you should be good to go.
Once done select no editor from global config. Depending on your settings this may or may not be active for you. This is because you can set the editor for each individual user. So if you are the Super User select that fron the user manager and you can select your editor of choice there too. If you set it to default it will use whatever editor is set in the global settings.
Next, go to your module manager and create a new custom html module. Past in your code and publish it in the debug position. This will place your code right before the </body> tag as Google recommend here (http://www.google.com/support/googleanalytics/bin/answer.py?answer=55488&utm_source=DiscoverList&utm_medium=et&utm_campaign=en_us&hl=en).
Here is the output from my install on the desktop so you can see how it looks (this was a random key nicked from the google website, it is not a live one)
</div><div class="custom"> <META NAME="google-site-verification" CONTENT="+nxGUDJ4QpAZ5l9Bsjdi102tLVC21AIh5d1Nl23908vVuFHs34 =" /></div></body></html>
Hopefully that clears things up for you.
11000
codger
02-02-2011, 03:33 AM
It is the right way to do things as per Google. The tag should go just before the </body> tag, not inside the <head> as a previous poster stated.
Magic! This J! 1.6 is pretty cool and you, Phil are a star!
Just one thing: The latest from Google is that this should be in the <head> - honest! Many of us feel that putting it in the <head> could slow down page loading, but what do you think about this?
Btw, THANKS for your attention to this issue - from me at least - and no doubt many others???
phill luckhurst
02-02-2011, 03:48 AM
You are right, it does say in the latest version ot the doc to put it in the Head tag, my bad. I still belive this will slow down page loads but lets see what Google say. I'll have a think about how to plave it in the head.
Yep, the new ACL is good.
phill luckhurst
02-02-2011, 03:59 AM
OK, if you want it in the <head> then it will require the editing of a file but not in the JAT3 plugin.
First we need to copy a file from the plugins folder to the templates folder so copy
plugins>system>jat3>jat3>base-themes>default>blocks>head.php and copy it to
templates>ja_teline_iv>blocks>head.php
The new file will take precedence over the one in the plugin
In that you will see the following code, place your analytics code right at the bottom
<?php
/*
# ------------------------------------------------------------------------
# JA T3 System plugin for Joomla 1.6
# ------------------------------------------------------------------------
# Copyright (C) 2004-2009 J.O.O.M Solutions Co., Ltd. All Rights Reserved.
# @license - Copyrighted Commercial Software
# Author: J.O.O.M Solutions Co., Ltd
# Websites: http://www.joomlart.com - http://www.joomlancers.com
# This file may not be redistributed in whole or significant part.
# ------------------------------------------------------------------------
*/
?>
<script type="text/javascript">
var siteurl='<?php echo JURI::base(true) ?>/';
var tmplurl='<?php echo JURI::base(true)."/templates/".T3_ACTIVE_TEMPLATE ?>/';
var isRTL = <?php echo $this->isRTL()?'true':'false' ?>;
</script>
<jdoc:include type="head" />
<?php if (T3Common::mobile_device_detect()=='iphone'):?>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1; user-scalable=1;" />
<meta name="apple-touch-fullscreen" content="YES" />
<?php endif;?>
<?php if (T3Common::mobile_device_detect()):?>
<meta name="HandheldFriendly" content="true" />
<?php endif;?>
<link href="<?php echo T3Path::getUrl('images/favicon.ico') ?>" rel="shortcut icon" type="image/x-icon" />
<?php JHTML::stylesheet ('', 'templates/system/css/system.css') ?>
<?php JHTML::stylesheet ('', 'templates/system/css/general.css') ?>
<!--[if IE 7.0]>
<style>
.clearfix { display: inline-block; } /* IE7xhtml*/
</style>
<![endif]-->
Depending on your template this may not put it right before the </head> tag but it will put it very close. It all depends on what other extensions are loaded into Joomla which may load some of their own scripts after this.
mikac
02-02-2011, 06:09 PM
Thank you very much!
Already applied and it works.
Great effort!
tomasjoom
02-14-2011, 08:37 AM
Many Thanks !!!.
I have been crazy trying to find a solution to install the Google Analytics script in a JA Droid template with Joomla 1.6. I followed these instructions and they really did work.
:)
boost_it
03-10-2011, 07:45 AM
OK, if you want it in the <head> then it will require the editing of a file but not in the JAT3 plugin.
First we need to copy a file from the plugins folder to the templates folder so copy
plugins>system>jat3>jat3>base-themes>default>blocks>head.php and copy it to
templates>ja_teline_iv>blocks>head.php
The new file will take precedence over the one in the plugin
In that you will see the following code, place your analytics code right at the bottom
<?php
/*
# ------------------------------------------------------------------------
# JA T3 System plugin for Joomla 1.6
# ------------------------------------------------------------------------
# Copyright (C) 2004-2009 J.O.O.M Solutions Co., Ltd. All Rights Reserved.
# @license - Copyrighted Commercial Software
# Author: J.O.O.M Solutions Co., Ltd
# Websites: http://www.joomlart.com - http://www.joomlancers.com
# This file may not be redistributed in whole or significant part.
# ------------------------------------------------------------------------
*/
?>
<script type="text/javascript">
var siteurl='<?php echo JURI::base(true) ?>/';
var tmplurl='<?php echo JURI::base(true)."/templates/".T3_ACTIVE_TEMPLATE ?>/';
var isRTL = <?php echo $this->isRTL()?'true':'false' ?>;
</script>
<jdoc:include type="head" />
<?php if (T3Common::mobile_device_detect()=='iphone'):?>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1; user-scalable=1;" />
<meta name="apple-touch-fullscreen" content="YES" />
<?php endif;?>
<?php if (T3Common::mobile_device_detect()):?>
<meta name="HandheldFriendly" content="true" />
<?php endif;?>
<link href="<?php echo T3Path::getUrl('images/favicon.ico') ?>" rel="shortcut icon" type="image/x-icon" />
<?php JHTML::stylesheet ('', 'templates/system/css/system.css') ?>
<?php JHTML::stylesheet ('', 'templates/system/css/general.css') ?>
<!--[if IE 7.0]>
<style>
.clearfix { display: inline-block; } /* IE7xhtml*/
</style>
<![endif]-->
Depending on your template this may not put it right before the </head> tag but it will put it very close. It all depends on what other extensions are loaded into Joomla which may load some of their own scripts after this.
Hi Phil
I'm using the JA Community Plus template (1.6) and the templates>ja_community_plus>blocks>
does not have "head.php". Is it in a different location in this instance?
phill luckhurst
03-10-2011, 01:50 PM
As per above, you simply copy that file from the plugins>system>jat3>jat3>base-themes>default>blocks>head.php into templates>ja_community_plus>blocks first.
nicualbc
06-27-2011, 05:41 AM
As per above, you simply copy that file from the plugins>system>jat3>jat3>base-themes>default>blocks>head.php into templates>ja_community_plus>blocks first.
Good topic. I did it :)
But, sorry, not sure if it is working correctly. I need more help, please.
On Analytics Settings > Profile Settings > Tracking Code is telling me ...
Waiting for Data. Analytics has been successfully installed and data is being gathered now.
So, it is OK if I put the script which google is giving me or I have to put meta, in the way you describe earlier, in this topic? What will be the difference if I will put meta?
If is necessarily to put meta, where I may found the code which I need? Google is giving me only a web property ID.
Many Thanks!
phill luckhurst
06-28-2011, 06:09 PM
Please post the code you are trying to use. Google does explain in full what they need you to add to your webpage.
mboomer
10-20-2011, 09:21 PM
I'm using the ja-purity ii template and I already have a head.php in the /blocks folder....do I over write this with the one from the plugin folder or just add the GA code to the bottom of the existing one?
phill luckhurst
10-20-2011, 09:48 PM
Simply add it to the one you already have there. This is an override so is different to the one already in the plugins folder and has some code specifically for the purity ii template so you need to keep that one.
mboomer
10-20-2011, 09:57 PM
I added it to the head.php in the /jat3 folder and this adds the code to all articles but doesn't add it to the home page. I'm guessing that will be the same for the head.php in the template folder.
What do I need to do to add it to site home (landing) page?
phill luckhurst
10-20-2011, 10:04 PM
Add it to the head.php in the templates folder and then make sure you clear all your caches including the jat3 cache and you should be good to go.
mboomer
10-20-2011, 11:06 PM
When you say clear all the caches, what exactly do you mean.
With the administrator I can use the JAT3 cache option but do I need to reset the cache somewhere else as well.
phill luckhurst
10-20-2011, 11:28 PM
Yes, there is the normal Joomla cache and also your browsers cache. The analytics should appear on your homepage as long as the code is present in the templates head.php file
mboomer
10-21-2011, 03:54 AM
I cleared the jat3 cache and I also cleared the joomla maintenance / clear cache option and it had an odd effect...the header images which I had changed don't display anymore and the default (leafy) header images are now displaying...even though the only files in the template/images/ folder are my changed header files.
phill luckhurst
10-21-2011, 04:13 AM
You must have changed something incorrectly. You will need to review your edits and check again. Before doing any work like this it is always a good idea to disable all caches and in the case of jat3 based templates, go into the template manager and set CSS and JS optimisation to "no" and enable development mode. Ths way you should be able to see the correct files to edit with tools such as firebug.
mboomer
10-21-2011, 05:23 AM
I'm not sure why clearing the joomla cache caused this but I copied the customised header files from
/templates/ja_purity_ii/images/header
in to the folder
/templates/ja_purity_ii/images
and thats displaying them correctly again.
I also have the google analytics code inserted correctly on the home page and all articles.
Thanks for your help.
scott_see
04-14-2012, 07:27 AM
It does work, I have tested it. For it to work you must switch off the editor in Global Config, not in the manager itself or Tiny still does the nasty deed. So go to global config and select "No Editor" as your default then try again.
phill,
I tried selecting "No Editor" in Global Config, but how do I turn that back on for other articles? If I'm not inserting code, I still want the WYSIWIG editor.
Thanks,
Scott
ksmall24
10-19-2012, 12:14 AM
Phil,
I'm just trying to be careful to not make a mistake. Perhaps overly so, but rather be safe than sorry.
I didn't see the code you pasted display. Do you paste the entire file from jat3 to teline iv header.php or just a portion? Before or after?
Thanks
magdacxz
10-19-2012, 08:26 AM
Great answer,very clear explanation!:)
Saguaros
10-19-2012, 04:01 PM
I believe this thread may helps: http://www.joomlart.com/forums/showthread.php?78278-How-to-Install-Google-Analytics-to-T3-Templates
richnyc30
02-27-2013, 10:02 AM
My client is using Teline IV. I have tried putting code into a HTML module and putting it in debug. The code seems to disappear if I go back to the regular editor and then back into HTML. Does it disappear if I just save the HTML in the html mode?
Google says to put the javascript into the templates. For Teline IV which files are the template files. I've looked at the site with FTP and not sure which are the template files to insert the code.
phill luckhurst
02-27-2013, 03:09 PM
Please see the following thread for instructions - http://www.joomlart.com/forums/showthread.php?78278-How-to-Install-Google-Analytics-to-T3-Templates
tomasjoom
02-27-2013, 07:32 PM
Phill,
Thank you. I did follow your instructions and place the GA tracker in the header.php file. I'm working with JA Mixmaz 2.5.
Today I checked the "source file" of my Home page and I realized I have the tracker installed 3 times. I believe it is due that I also have the Async Tracking plugin and the GA Dashboard installed. Is this going to affect the statistics?. Do Google will know that it is the same tracking code?.
Even the tracking code is reflected in the Home page source file, when I go to my Google Analytics account and select the domain, Google is still telling me that the tracking is not installed but it is giving me some statistics. Any ideas?.
Thanks,
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.