Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
0.14.0 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
fooman committed Apr 14, 2014
1 parent 41e573b commit 3605c01
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,38 @@ public function getProductCategory($product)
}
return false;
}

/**
* Return REQUEST_URI for current page
* Magento default analytics reports can include the same page as
* /checkout/onepage/index/ and /checkout/onepage/
* filter out index/ here and unify to no trailing /
*
* @return string
*/
public function getPageName()
{
if (!$this->hasData('page_name')) {
$parts = parse_url(
Mage::getSingleton('core/url')->escape(
Mage::app()->getRequest()->getServer('REQUEST_URI')
)
);
$query = '';
if (isset($parts['query']) && !empty($parts['query'])) {
$query = '?' . $parts['query'];
}

$url = Mage::getSingleton('core/url')->escape(
rtrim(
str_replace(
'index/', '',
Mage::app()->getRequest()->getBaseUrl() . Mage::app()->getRequest()->getRequestString()
), '/'
). $query
);
$this->setPageName($url);
}
return $this->getData('page_name');
}
}
19 changes: 0 additions & 19 deletions app/code/community/Fooman/GoogleAnalyticsPlus/Block/Ga.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,6 @@ protected function _construct()
$this->_helper = Mage::helper('googleanalyticsplus');
}

/**
* Return REQUEST_URI for current page
* Magento default analytics reports can include the same page as
* /checkout/onepage/index/ and /checkout/onepage/
* filter out index/ here
*
* @return string
*/
public function getPageName()
{
if (!$this->hasData('page_name')) {
$pageName = Mage::getSingleton('core/url')->escape(
Mage::app()->getRequest()->getServer('REQUEST_URI')
);
$pageName = rtrim(str_replace('index/', '', $pageName), '/');
$this->setPageName($pageName);
}
return $this->getData('page_name');
}

/**
* get the current url to send to Google Analytics
Expand Down
23 changes: 21 additions & 2 deletions app/code/community/Fooman/GoogleAnalyticsPlus/Block/Universal.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected function _construct()
public function shouldInclude()
{
if (parent::shouldInclude()) {
return $this->isUniversalEnabled() && (bool)$this->getUniversalSnippet();
return $this->isUniversalEnabled() && (bool)$this->getUniversalAccount();
} else {
return false;
}
Expand All @@ -45,10 +45,29 @@ public function isUniversalEnabled()
/**
* get universal snippet from settings
*
* @deprecated sind 0.14.0
* @return string
*/
public function getUniversalSnippet()
{
return Mage::getStoreConfig('google/analyticsplus_universal/snippet');
return '';
}

/**
* get Google Analytics account id
*
* @return mixed
*/
public function getUniversalAccount()
{
return Mage::getStoreConfig('google/analyticsplus_universal/accountnumber');
}

/**
* @return bool
*/
public function getUniversalAnonymise()
{
return Mage::getStoreConfigFlag('google/analyticsplus_universal/anonymise');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config>
<modules>
<Fooman_GoogleAnalyticsPlus>
<version>0.13.19</version>
<version>0.14.0</version>
<depends>
<Mage_GoogleAnalytics/>
</depends>
Expand Down
22 changes: 16 additions & 6 deletions app/code/community/Fooman/GoogleAnalyticsPlus/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,25 @@
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</enabled>
<snippet translate='label'>
<label>Tracking Code</label>
<frontend_type>textarea</frontend_type>
<sort_order>20</sort_order>
<accountnumber translate="label">
<label>Account Number</label>
<comment/>
<frontend_type>text</frontend_type>
<sort_order>100</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<depends><enabled>1</enabled></depends>
</snippet>
</accountnumber>
<anonymise translate="label">
<label>Anonymise IP Address</label>
<comment><![CDATA[See <a href="https://support.google.com/analytics/answer/2763052?hl=en</a> for details]]></comment>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>200</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</anonymise>
</fields>
</analyticsplus_universal>
<analyticsplus_tagmanager translate="label">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
<?php if ($this->shouldInclude()): ?>
<?php echo $this->getUniversalSnippet(); ?>
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', '<?php echo $this->getUniversalAccount(); ?>', 'auto');
<?php if($this->getUniversalAnonymise()):?>
ga('set', 'anonymizeIp', true);
<?php endif;?>
ga('send', 'pageview', '<?php echo $this->getPageName(); ?>');

</script>
<?php if($this->isSuccessPage()):?>
<?php $order = $this->_getOrder();?>
<script>
Expand Down Expand Up @@ -27,4 +40,5 @@
/* ]]> */
</script>
<?php endif; ?>
<!-- End Google Analytics -->
<?php endif; ?>

0 comments on commit 3605c01

Please sign in to comment.