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

Commit

Permalink
0.15.1 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
fooman committed Oct 9, 2014
1 parent 9935e32 commit 9e35138
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function getAlternativeAccountId()
}

/**
* get Google Analytics account id
* get Google Analytics universal account id
*
* @return mixed
*/
Expand All @@ -179,6 +179,16 @@ public function getUniversalAccount()
return Mage::getStoreConfig('google/analyticsplus_universal/accountnumber');
}

/**
* get Google Analytics universal account id for alternative profile
*
* @return mixed
*/
public function getAlternativeUniversalAccount()
{
return Mage::getStoreConfig('google/analyticsplus_universal/altaccountnumber');
}

/**
* are we using universal
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
class Fooman_GoogleAnalyticsPlus_Block_Universal extends Fooman_GoogleAnalyticsPlus_Block_GaConversion
{
const TRACKER_TWO_NAME = 'tracker2';

protected function _construct()
{
parent::_construct();
Expand Down Expand Up @@ -55,9 +57,11 @@ public function getUniversalAnonymise()
/**
* Build any params that is passed on create of analytics object
*
* @param bool $createTrackerTwo
*
* @return string
*/
public function getUniversalParams()
public function getUniversalParams($createTrackerTwo = false)
{
$params = array();
if (Mage::getStoreConfig('google/analyticsplus_universal/domainname')) {
Expand All @@ -66,6 +70,9 @@ public function getUniversalParams()
if ($this->canUseUniversalUserTracking()) {
$params['userId'] = $this->getCustomerId();
}
if ($createTrackerTwo) {
$params['name'] = self::TRACKER_TWO_NAME;
}
if (count($params) == 0) {
return "'auto'";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config>
<modules>
<Fooman_GoogleAnalyticsPlus>
<version>0.15.0</version>
<version>0.15.1</version>
</Fooman_GoogleAnalyticsPlus>
</modules>

Expand Down
9 changes: 9 additions & 0 deletions app/code/community/Fooman/GoogleAnalyticsPlus/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,15 @@
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</accountnumber>
<altaccountnumber translate="label">
<label>Account Number (alternative Profile)</label>
<comment/>
<frontend_type>text</frontend_type>
<sort_order>150</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</altaccountnumber>
<anonymise translate="label">
<label>Anonymise IP Address</label>
<comment><![CDATA[See <a href="https://support.google.com/analytics/answer/2763052?hl=en">Google Documentation</a> for details]]></comment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
this.classic = settings.classic;
this.altClassic = settings.altClassic;
this.universal = settings.universal;
this.altUniversal = settings.altUniversal;
},
trackEvent: function(section){

Expand All @@ -22,6 +23,9 @@
if (this.universal) {
ga('send', 'pageview', urlToTrack);
}
if (this.altUniversal) {
ga('<?php echo Fooman_GoogleAnalyticsPlus_Block_Universal::TRACKER_TWO_NAME?>.send', 'pageview', urlToTrack);
}
}
}

Expand All @@ -30,7 +34,8 @@
pageQuery: '<?php echo $this->getPageQuery() ?>',
classic: '<?php echo $this->getMainAccountId() ?>',
altClassic: '<?php echo $this->getAlternativeAccountId() ?>',
universal: '<?php echo $this->isUniversalEnabled() ? $this->getUniversalAccount():'' ?>'
universal: '<?php echo $this->isUniversalEnabled() ? $this->getUniversalAccount():'' ?>',
altUniversal: '<?php echo $this->isUniversalEnabled() ? $this->getAlternativeUniversalAccount():'' ?>'
}
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php if ($this->shouldInclude()): ?>
<?php $altUniversal = $this->getAlternativeUniversalAccount(); ?>
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
Expand All @@ -7,40 +8,75 @@
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', '<?php echo $this->getUniversalAccount(); ?>',<?php echo $this->getUniversalParams(); ?>);
<?php if ($altUniversal):?>
ga('create', '<?php echo $altUniversal; ?>',<?php echo $this->getUniversalParams(true); ?>);
<?php endif;?>

<?php if($this->getUniversalAnonymise()):?>
ga('set', 'anonymizeIp', true);
<?php if ($altUniversal):?>
ga('<?php echo Fooman_GoogleAnalyticsPlus_Block_Universal::TRACKER_TWO_NAME?>.set', 'anonymizeIp', true);
<?php endif;?>
<?php endif;?>
<?php if($this->getUniversalDisplayAdvertising()):?>
ga('require', 'displayfeatures'<?php if($this->getUniversalDisplayAdvertisingCookieName()):?>, undefined, { cookieName: '<?php echo $this->getUniversalDisplayAdvertisingCookieName(); ?>' }<?php endif; ?>);
<?php if ($altUniversal):?>
ga('<?php echo Fooman_GoogleAnalyticsPlus_Block_Universal::TRACKER_TWO_NAME?>.require', 'displayfeatures'<?php if($this->getUniversalDisplayAdvertisingCookieName()):?>, undefined, { cookieName: '<?php echo $this->getUniversalDisplayAdvertisingCookieName(); ?>' }<?php endif; ?>);
<?php endif;?>
<?php endif;?>
ga('send', 'pageview', '<?php echo $this->getPageName(); ?>');
<?php if ($altUniversal):?>
ga('<?php echo Fooman_GoogleAnalyticsPlus_Block_Universal::TRACKER_TWO_NAME?>.send', 'pageview', '<?php echo $this->getPageName(); ?>');
<?php endif;?>

</script>
<?php if($this->isSuccessPage()):?>
<?php $order = $this->_getOrder();?>
<script>
/* <![CDATA[ */
ga('require', 'ecommerce', 'ecommerce.js');
<?php if ($altUniversal):?>
ga('<?php echo Fooman_GoogleAnalyticsPlus_Block_Universal::TRACKER_TWO_NAME?>.require', 'ecommerce', 'ecommerce.js');
<?php endif;?>

<?php $transactionDetails = "{
'id': '".$this->jsQuoteEscape($order->getIncrementId()) ."',
'affiliation': '". $this->jsQuoteEscape(Mage::app()->getStore()->getName()) ."',
'revenue': '". Mage::helper('googleanalyticsplus')->convert($order, 'grand_total') ."',
'shipping': '". Mage::helper('googleanalyticsplus')->convert($order, 'shipping_amount') ."',
'tax': '". Mage::helper('googleanalyticsplus')->convert($order, 'tax_amount') ."',
'currency': '". Mage::helper('googleanalyticsplus')->getTrackingCurrency($order) ."'
}";
?>

ga('ecommerce:addTransaction', <?php echo $transactionDetails?>);
<?php if ($altUniversal):?>
ga('<?php echo Fooman_GoogleAnalyticsPlus_Block_Universal::TRACKER_TWO_NAME?>.ecommerce:addTransaction', <?php echo $transactionDetails?>);
<?php endif;?>


ga('ecommerce:addTransaction', {
'id': '<?php echo $this->jsQuoteEscape($order->getIncrementId()) ?>',
'affiliation': '<?php echo $this->jsQuoteEscape(Mage::app()->getStore()->getName()) ?>',
'revenue': '<?php echo Mage::helper('googleanalyticsplus')->convert($order, 'grand_total') ?>',
'shipping': '<?php echo Mage::helper('googleanalyticsplus')->convert($order, 'shipping_amount') ?>',
'tax': '<?php echo Mage::helper('googleanalyticsplus')->convert($order, 'tax_amount') ?>',
'currency': '<?php echo Mage::helper('googleanalyticsplus')->getTrackingCurrency($order) ?>'
});
<?php foreach ($order->getAllVisibleItems() as $item):?>
ga('ecommerce:addItem', {
'id': '<?php echo $this->jsQuoteEscape($order->getIncrementId()) ?>',
'name': '<?php echo $this->jsQuoteEscape($item->getName())?>',
'sku': '<?php echo $this->jsQuoteEscape($item->getSku())?>',
'price': '<?php echo Mage::helper('googleanalyticsplus')->convert($item, 'price')?>',
'quantity': '<?php echo (int)$item->getQtyOrdered()?>',
'category': '<?php echo $this->jsQuoteEscape($this->getCategory($item))?>'
});

<?php $itemDetails = "{
'id': '".$this->jsQuoteEscape($order->getIncrementId()) ."',
'name': '". $this->jsQuoteEscape($item->getName()) ."',
'sku': '". $this->jsQuoteEscape($item->getSku()) ."',
'price': '". Mage::helper('googleanalyticsplus')->convert($item, 'price') ."',
'quantity': '". (int)$item->getQtyOrdered() ."',
'category': '". $this->jsQuoteEscape($this->getCategory($item)) ."'
}";
?>


ga('ecommerce:addItem', <?php echo $itemDetails?>);
<?php if ($altUniversal):?>
ga('<?php echo Fooman_GoogleAnalyticsPlus_Block_Universal::TRACKER_TWO_NAME?>.ecommerce:addItem', <?php echo $itemDetails?>);
<?php endif;?>
<?php endforeach;?>
ga('ecommerce:send');
<?php if ($altUniversal):?>
ga('<?php echo Fooman_GoogleAnalyticsPlus_Block_Universal::TRACKER_TWO_NAME?>.ecommerce:send');
<?php endif;?>
/* ]]> */
</script>
<?php endif; ?>
Expand Down

0 comments on commit 9e35138

Please sign in to comment.