Example #1
0
 /**
  * Render GA tracking scripts
  *
  * @return string
  */
 protected function _toHtml()
 {
     if (!$this->_isAvailable()) {
         return '';
     }
     return parent::_toHtml();
 }
Example #2
0
 /**
  * Prepare and return block's html output
  *
  * @return string Google Analytics JS Tracking Code
  */
 protected function _toHtml()
 {
     $html = parent::_toHtml();
     if (!Mage::getStoreConfigFlag(self::CONFIG_GOOGLE_ANALYTICS_IP_ANONYMIZATION)) {
         return $html;
     }
     $matches = array();
     $setAccountExpression = '/_gaq\\.push\\(\\[\'_setAccount\', \'[a-zA-Z0-9-_]+\'\\]\\);\\n/';
     $append = '_gaq.push([\'_gat._anonymizeIp\']);';
     if (preg_match_all($setAccountExpression, $html, $matches) && count($matches) && count($matches[0])) {
         $html = preg_replace($setAccountExpression, $matches[0][0] . $append . "\n", $html);
     }
     return $html;
 }