Anonymized Google Analytics

Feel free to talk about everything related to our Joomla Products
Rate this topic: Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.Evaluations: 0, 0.00 on the average.
GK User
Thu Dec 01, 2011 9:09 pm
In Germany we are forced to anonymize the IP addresses in Analytics for privacy reasons. So it is necessary to use "gat._anonymizeIp()".

It is possible to include this feature into the framework as an optional switch?

Thanks in advance
User avatar
Fresh Boarder

teitbite
Thu Dec 01, 2011 10:05 pm
Hi

You probably should leave the template configuration in this point and add GA code manualy in /layouts/default.php this way You will be able to add this option also.
User avatar
Moderator

GK User
Wed Oct 24, 2012 2:40 pm
Hi, I have another question on this.
I have to change:

___________________________________
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-y']);
_gaq.push(['_trackPageview']);

into:
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-y']);
_gaq.push(['_gat._anonymizeIp']);
_gaq.push(['_trackPageview']);
___________________________________

but in the head layouts/default.php I can only find something like this:


___________________________________
<head>

<?php if($this->getParam("chrome_frame_support", '0') == '1') : ?>
<meta http-equiv="X-UA-Compatible" content="chrome=1"/>
<?php endif; ?>

<meta http-equiv="X-UA-Compatible" content="IE=9" />

<jdoc:include type="head" />
<?php $this->loadBlock('head'); ?>
</head>
___________________________________

which is the best way to add:

___________________________________
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-y']);
_gaq.push(['_gat._anonymizeIp']);
_gaq.push(['_trackPageview']);
___________________________________

thanks for help;)
User avatar
Junior Boarder

teitbite
Thu Oct 25, 2012 11:19 am
Hi

That's because this code is being loaded from within an extension. You need to find files of this extension and modificate it there, but it can be hard. I think easier will be to disable extension ading this code and simply add it manualy into head.php file.
User avatar
Moderator

GK User
Fri Oct 26, 2012 10:44 am
Yes, but I haven't install any extention it must be inside the template and so what is the best way to add the anonymize IP code? Thanks for help;)
User avatar
Junior Boarder

teitbite
Sat Oct 27, 2012 11:54 am
Hi

Please simply remove any GA Api from template settings and it will not be used. Than add whole the code with modifications directly into /layouts/blocks/head.php
User avatar
Moderator

GK User
Sat Oct 27, 2012 12:18 pm
ok, that`s easy - a last question:

this is the head.php: (layouts/blocks/head.php) - how to put the Tracking code inside (at the end) - simply at the bottom??
thanks;)


<?php

// This is the code which will be placed in the head section

// No direct access.
defined('_JEXEC') or die;

$favicon_image = $this->getParam('favicon_image', '');

if($favicon_image == '') {
$favicon_image = $this->URLtemplate() . '/images/favicon.ico';
} else {
$favicon_image = $this->URLbase() . $favicon_image;
}

$this->API->addFavicon($favicon_image);

?>

<?php

if($this->browser->get('browser') != 'ie6') {
// check the color version
$template_style = '';
if($this->getParam("stylearea", 1)) $template_style = (isset($_COOKIE['gk2_style']) ? $_COOKIE['gk2_style'] : $this->getParam("template_color", 1));
else $template_style = $this->getParam("template_color", 1);
// load the CSS files
if($this->getParam('reset_css', '') != '') {
$this->addCSS($this->URLtemplate() . '/css/reset/'.$this->getParam('reset_css', '').'.css');
}

$this->addCSS($this->URLtemplate() . '/css/layout.css');
$this->addCSS($this->URLtemplate() . '/css/joomla.css');
$this->addCSS($this->URLtemplate() . '/css/template.css');
$this->addCSS($this->URLtemplate() . '/css/menu.css');
$this->addCSS($this->URLtemplate() . '/css/gk.stuff.css');

if($this->getParam('typography', '1') == '1') {
$this->addCSS($this->URLtemplate() . '/css/typography.style'.$template_style.'.css');
if($this->getParam('typo_iconset1', '1') == '1') $this->addCSS($this->URLtemplate() . '/css/typography.iconset.1.css');
if($this->getParam('typo_iconset2', '1') == '1') $this->addCSS($this->URLtemplate() . '/css/typography.iconset.2.css');
if($this->getParam('typo_iconset3', '1') == '1') $this->addCSS($this->URLtemplate() . '/css/typography.iconset.3.css');
}

$this->addCSS($this->URLtemplate() . '/css/style'.$template_style.'.css');

if($this->getParam("css_override", '0')) {
$this->addCSS($this->URLtemplate() . '/css/override.css');
}

if($this->getParam("css_custom", '') != '') {
$this->addCSSRule($this->getParam('css_custom', ''));
}

$this->useCache($this->getParam('css_compression', '0'), $this->getParam('css_cache', '0'));
// include fonts
$font_iter = 1;

while($this->getParam('font_name_group'.$font_iter, 'gkFontNull') !== 'gkFontNull') {
$font_data = explode(';', $this->getParam('font_name_group'.$font_iter, ''));
if(isset($font_data) && count($font_data) >= 2) {
$font_type = $font_data[0];
$font_name = $font_data[1];
if($this->getParam('font_rules_group'.$font_iter, '') != ''){
if($font_type == 'standard') {
$this->addCSSRule($this->getParam('font_rules_group'.$font_iter, '') . ' { font-family: ' . $font_name . '; }'."\n");
} elseif($font_type == 'google') {
if($font_name != 'own') {
echo '<link href="http://fonts.googleapis.com/css?family='.$font_name.'" rel="stylesheet" type="text/css" />';

$gfont = $font_name;

if(stripos($gfont, ':') !== FALSE) {
$gfont_cut = stripos($gfont, ':');
$gfont = substr($gfont, 0, $gfont_cut);
}

$this->addCSSRule($this->getParam('font_rules_group'.$font_iter, '') . ' { font-family: \''.str_replace('+', ' ', $gfont). '\', Arial, sans-serif; }'."\n");
} else {
$font_link = $font_data[2];
$font_family = $font_data[3];

echo '<link href="'.$font_link.'" rel="stylesheet" type="text/css" />';

$this->addCSSRule($this->getParam('font_rules_group'.$font_iter, '') . ' { font-family: \''.$font_family.'\', Arial, sans-serif; }'."\n");
}
} elseif($font_type == 'squirrel') {
echo '<link href="'. $this->URLtemplate() . '/fonts/' . $font_name . '/stylesheet.css" rel="stylesheet" type="text/css" />';
$this->addCSSRule($this->getParam('font_rules_group'.$font_iter, '') . ' { font-family: ' . $font_name . ', Arial, sans-serif; }'."\n");
}
}
}

$font_iter++;
}
// include JavaScript
$this->addJS($this->URLtemplate() . '/js/gk.scripts.js');

if($this->browser->get('browser') == 'ie7') {
$this->addJS($this->URLtemplate() . '/js/ie7.equal.columns.js');
}

if($this->getParam('selectivizr', '0') == 1 && ($this->browser->get('browser') == 'ie7' || $this->browser->get('browser') == 'ie8')) {
$this->addJS($this->URLtemplate() . '/js/selectivizr.js');
}

$this->addJSFragment(' $GKMenu = { height:'.($this->getParam('menu_height','0') == 1 ? 'true' : 'false') .', width:'.($this->getParam('menu_width','0') == 1 ? 'true' : 'false') .', duration: '.($this->getParam('menu_duration', '500')).' };');


$this->addJSFragment('$GK_TMPL_URL = "' . $this->URLtemplate() . '";');

?>

<!--[if IE 9.0]><link rel="stylesheet" href="<?php echo $this->URLtemplate(); ?>/css/ie9.css" type="text/css" /><![endif]-->
<!--[if IE 8.0]><link rel="stylesheet" href="<?php echo $this->URLtemplate(); ?>/css/ie8.css" type="text/css" /><![endif]-->
<!--[if IE 7.0]><link rel="stylesheet" href="<?php echo $this->URLtemplate(); ?>/css/ie7.css" type="text/css" /><![endif]-->

<?php

} else {

// IE6 code
$this->addCSS( $this->URLtemplate(). '/css/ie6.css');

}

___________________________________________
<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
_gaq.push (['_gat._anonymizeIp']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>
User avatar
Junior Boarder

teitbite
Sat Oct 27, 2012 1:37 pm
Hi

Yes. All the code from this file appears between <head></head> so any place is fine, but for sure the end of this file is the easiest to handle.
User avatar
Moderator

GK User
Sat Oct 27, 2012 2:12 pm
Hm, the syntax isn`t right?

Parse error: syntax error, unexpected '<' in /www/htdocs/.../templates/gk_postnote/layouts/blocks/head.php on line 126

??? sorry, I`m not a programmer - which is the right syntax?? bevore the last } - behind doesn't work.
Thanks again
User avatar
Junior Boarder

teitbite
Mon Oct 29, 2012 9:00 am
Hi

As I see in the example of the code above. You just need to care and not to put javascript code inside php code which is placed between <?php ?> tags.

Please send me an access to ftp and a part of the code You want to copy and I'll do this for You if You have problems.
User avatar
Moderator

teitbite
Wed Oct 31, 2012 1:48 pm
Hi

I have an FTP access from You, but I have no rights to change anything. So I'm gonna describe what I was going to do here:

1. Remove the line which is responsible for adding google analitics code in template, file: /layout/blocks/social.php line 109

Code: Select all
   echo $this->googleAnalyticsParser();


2. In /layout/blocks/head.php add the code for GA at the very end of this file (I've also noticed that You have an error in this file, probably made during trying - mean that a value "?>" is missing at the end of it). When You will fix this file, simply go to the end, hit enter and copy the code You've send me by mail:

Code: Select all
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'xxxxxxxxxxx']);
  _gaq.push (['_gat._anonymizeIp']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>
User avatar
Moderator

teitbite
Sun Nov 04, 2012 1:59 pm
Hi

Ok. My access to FTP worked now. I've copied the code to it. Please check head.php file and tell me if it's working fine now.
User avatar
Moderator

GK User
Sun Nov 04, 2012 6:16 pm
Hi, yes now it works - I hope google find it in the next 24 hours.
Thanks for your help;)
User avatar
Junior Boarder

teitbite
Mon Nov 05, 2012 12:48 pm
Hi

I'm glad it's working :) To be honest I've seen Google catch up after 2 weeks in some cases :( Hope it's not such case :)
User avatar
Moderator

GK User
Mon Nov 05, 2012 4:22 pm
no, no it`s working now - Google had recognize the site - it`s fine - thanks I`m happy - and thanks for your help :D
User avatar
Junior Boarder

teitbite
Mon Nov 05, 2012 7:26 pm
Hi

Ok. Than there is nothing left to add :) I'm glad I could help.
User avatar
Moderator

GK User
Thu Nov 22, 2012 2:47 pm
This worked perfectly for me with the GK Startup!
User avatar
Fresh Boarder


cron