avoid js errors because of empty NoBounceEventTime, tpl blocks added

This commit is contained in:
Daniel Seifert 2015-06-03 07:57:45 +00:00
parent d760ff512b
commit 3742b80fb3
3 changed files with 47 additions and 32 deletions

View File

@ -173,11 +173,9 @@
[{/if}]
[{* bounce optimization*}]
[{block name="d3ga_bounceoptimzation"}]
[{block name="d3ga_bounceoptimization"}]
[{if $oD3GASettings->getValue('blUseBounceRateOptimization')}]
[{if $oD3GASettings->getValue('iSendNoBounceEventTime')}]
setTimeout('_gaq.push([\'_trackEvent\', \'NoBounce\', \'Over defined seconds\'])',[{$oD3GASettings->getValue('iSendNoBounceEventTime')}]);
[{/if}]
setTimeout('_gaq.push([\'_trackEvent\', \'NoBounce\', \'Over defined seconds\'])',[{$iD3GASendNoBounceEventTime}]);
[{if $oD3GASettings->getValue('blSendNoBounceEventScroll')}]
window.addEventListener ?

View File

@ -2,6 +2,7 @@
[{capture name="d3GATrackCode"}]
[{strip}]
[{if $oD3GASettings->getValue('blD3GAUseOptOut')}]
[{block name="d3ga_optoutscript"}]
<script type="text/javascript">
var gaProperty = '[{$oD3GASettings->getValue('sD3GAId')}]';
var disableStr = 'ga-disable-' + gaProperty;
@ -14,6 +15,7 @@
window[disableStr] = true;
}
</script>
[{/block}]
[{/if}]
<script type="text/javascript">
@ -52,11 +54,9 @@
[{/if}]
[{* bounce optimization*}]
[{block name="d3ga_bounceoptimzation"}]
[{block name="d3ga_bounceoptimization"}]
[{if $oD3GASettings->getValue('blUseBounceRateOptimization')}]
[{if $oD3GASettings->getValue('iSendNoBounceEventTime')}]
setTimeout('ga(\'send\', \'event\', \'NoBounce\', \'Over defined seconds\')',[{$oD3GASettings->getValue('iSendNoBounceEventTime')}]);
[{/if}]
setTimeout('ga(\'send\', \'event\', \'NoBounce\', \'Over defined seconds\')',[{$iD3GASendNoBounceEventTime}]);
[{if $oD3GASettings->getValue('blSendNoBounceEventScroll')}]
window.addEventListener ?
@ -79,6 +79,7 @@
[{include file="d3ga_universal_ecommerce.tpl"}]
[{if $oD3GASettings->getValue('blD3GATrackPageLoadTime')}]
[{block name="d3ga_trackpageloadtime"}]
var perfData = window.performance.timing;
var pageLoadTime = perfData.domComplete - perfData.navigationStart;
var loadTime = "";
@ -94,6 +95,7 @@
ga('set', 'metric1', loadTime);
[{*ga('send', 'event', 'Page Load Time', loadTime, {'nonInteraction': true});*}]
[{/block}]
[{/if}]
</script>

View File

@ -53,6 +53,7 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
$oParentView->addTplParam('sD3GASendPageViewParameter', $this->d3getSendPageViewParameters());
$oParentView->addTplParam('sD3CurrentShopUrl', $this->d3GetCreateCurrentShopUrl());
$oParentView->addTplParam('blD3GAIsMobile', $this->d3isMobile());
$oParentView->addTplParam('iD3GASendNoBounceEventTime', $this->d3GetSendNoBounceEventTime());
if ($oSet->getValue('sD3GATSActive') && $oSet->getValue('sD3GATSShoppingActive')) {
$aInfos = $this->d3GATSGetProdInfos();
@ -566,4 +567,18 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
return false;
}
/**
* @return int
*/
public function d3GetSendNoBounceEventTime()
{
$iTime = d3_cfg_mod::get($this->_sModId)->getValue('iSendNoBounceEventTime');
if (isset($iTime) && is_int($iTime)) {
return $iTime;
}
return 10000;
}
}