initial implementation for gtag
# Conflicts: # copy_this/modules/d3/d3_googleanalytics/metadata.php
This commit is contained in:
parent
23ffbf090f
commit
d6f6a7652b
@ -32,10 +32,6 @@ class d3_cfg_googleanalytics_adwords extends d3_cfg_mod_main
|
||||
*/
|
||||
public function getGaType()
|
||||
{
|
||||
if ($this->d3GetSet()->getValue('sD3GAType') == 'async') {
|
||||
return 'async';
|
||||
}
|
||||
|
||||
return 'universal';
|
||||
return $this->d3GetSet()->getValue('sD3GAType');
|
||||
}
|
||||
}
|
||||
|
@ -32,10 +32,6 @@ class d3_cfg_googleanalytics_campaigns extends d3_cfg_mod_main
|
||||
*/
|
||||
public function getGaType()
|
||||
{
|
||||
if ($this->d3GetSet()->getValue('sD3GAType') == 'async') {
|
||||
return 'async';
|
||||
}
|
||||
|
||||
return 'universal';
|
||||
return $this->d3GetSet()->getValue('sD3GAType');
|
||||
}
|
||||
}
|
||||
|
@ -32,10 +32,6 @@ class d3_cfg_googleanalytics_main extends d3_cfg_mod_main
|
||||
*/
|
||||
public function getGaType()
|
||||
{
|
||||
if ($this->d3GetSet()->getValue('sD3GAType') == 'async') {
|
||||
return 'async';
|
||||
}
|
||||
|
||||
return 'universal';
|
||||
return $this->d3GetSet()->getValue('sD3GAType');
|
||||
}
|
||||
}
|
||||
|
@ -92,14 +92,13 @@ $aModule = array(
|
||||
'd3ga_universal_trustedstore.tpl' =>
|
||||
'd3/d3_googleanalytics/views/tpl/widget/inc/d3ga_universal_trustedstore.tpl',
|
||||
|
||||
'd3_cfg_googleanalytics_main.tpl' =>
|
||||
'd3/d3_googleanalytics/views/admin/tpl/d3_cfg_googleanalytics_main.tpl',
|
||||
'd3_cfg_googleanalytics_adwords.tpl' =>
|
||||
'd3/d3_googleanalytics/views/admin/tpl/d3_cfg_googleanalytics_adwords.tpl',
|
||||
'd3_cfg_googleanalytics_campaigns.tpl' =>
|
||||
'd3/d3_googleanalytics/views/admin/tpl/d3_cfg_googleanalytics_campaigns.tpl',
|
||||
'd3_cfg_googleanalytics_trustedstore.tpl' =>
|
||||
'd3/d3_googleanalytics/views/admin/tpl/d3_cfg_googleanalytics_trustedstore.tpl',
|
||||
'd3ga_gtag.tpl' => 'd3/d3_googleanalytics/views/tpl/widget/d3ga_gtag.tpl',
|
||||
'd3ga_gtag_ecommerce.tpl' => 'd3/d3_googleanalytics/views/tpl/widget/inc/d3ga_gtag_ecommerce.tpl',
|
||||
|
||||
'd3_cfg_googleanalytics_main.tpl' => 'd3/d3_googleanalytics/views/admin/tpl/d3_cfg_googleanalytics_main.tpl',
|
||||
'd3_cfg_googleanalytics_adwords.tpl' => 'd3/d3_googleanalytics/views/admin/tpl/d3_cfg_googleanalytics_adwords.tpl',
|
||||
'd3_cfg_googleanalytics_campaigns.tpl' => 'd3/d3_googleanalytics/views/admin/tpl/d3_cfg_googleanalytics_campaigns.tpl',
|
||||
'd3_cfg_googleanalytics_trustedstore.tpl' => 'd3/d3_googleanalytics/views/admin/tpl/d3_cfg_googleanalytics_trustedstore.tpl',
|
||||
),
|
||||
'events' => array(
|
||||
'onActivate' => 'd3install::checkUpdateStart',
|
||||
|
@ -1,5 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
|
||||
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
|
||||
|
||||
/**
|
||||
* This module is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -98,9 +102,11 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
|
||||
{
|
||||
if (d3_cfg_mod::get($this->_sModId)->getValue('sD3GAType') == 'async') {
|
||||
return 'd3_googleanalytics.tpl';
|
||||
} elseif (\D3\ModCfg\Application\Model\Configuration\d3_cfg_mod::get($this->_sModId)->getValue('sD3GAType') == 'universaal') {
|
||||
return 'd3ga_universal.tpl';
|
||||
} elseif (\D3\ModCfg\Application\Model\Configuration\d3_cfg_mod::get($this->_sModId)->getValue('sD3GAType') == 'gtag') {
|
||||
return 'd3ga_gtag.tpl';
|
||||
}
|
||||
|
||||
return 'd3ga_universal.tpl';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -226,6 +232,16 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
|
||||
{
|
||||
$aParameter = array();
|
||||
|
||||
if (\D3\ModCfg\Application\Model\Configuration\d3_cfg_mod::get($this->_sModId)->getValue('sD3GAType') == 'gtag') {
|
||||
$aParameter = $this->_d3getCreateAnonymizeIpParameter($aParameter);
|
||||
|
||||
/** @var oxUBase $oCurrentView */
|
||||
$oCurrentView = oxRegistry::getConfig()->getActiveView();
|
||||
$oCurrentView->getIsOrderStep();
|
||||
|
||||
$aParameter = $this->_d3getGtagSendPageViewPageParameter($oCurrentView, $aParameter);
|
||||
}
|
||||
|
||||
$aParameter = $this->_d3getCreateDomainNameParameter($aParameter);
|
||||
$aParameter = $this->_d3getCreateCookiePathParameter($aParameter);
|
||||
$aParameter = $this->_d3getCreateDomainLinkerParameter($aParameter);
|
||||
@ -246,9 +262,11 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
|
||||
{
|
||||
if (d3_cfg_mod::get($this->_sModId)->getValue('sD3GAType') == 'async') {
|
||||
return $this->_d3getAsyncSendpageViewParameters();
|
||||
} elseif (\D3\ModCfg\Application\Model\Configuration\d3_cfg_mod::get($this->_sModId)->getValue('sD3GAType') == 'universal') {
|
||||
return $this->_d3getUniversalSendPageViewParameters();
|
||||
} elseif (\D3\ModCfg\Application\Model\Configuration\d3_cfg_mod::get($this->_sModId)->getValue('sD3GAType') == 'gtag') {
|
||||
return $this->_d3getGtagSendPageViewParameters();
|
||||
}
|
||||
|
||||
return $this->_d3getUniversalSendPageViewParameters();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -292,6 +310,11 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function _d3getGtagSendPageViewParameters()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
@ -514,6 +537,22 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
|
||||
return $aParameter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $aParameter
|
||||
* @return array
|
||||
* @throws DBALException
|
||||
* @throws DatabaseConnectionException
|
||||
* @throws DatabaseErrorException
|
||||
*/
|
||||
protected function _d3getCreateAnonymizeIpParameter($aParameter)
|
||||
{
|
||||
if (\D3\ModCfg\Application\Model\Configuration\d3_cfg_mod::get($this->_sModId)->getValue('blD3GAAnonymizeIP')) {
|
||||
$aParameter[] = "'anonymize_ip': true'";
|
||||
}
|
||||
|
||||
return $aParameter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param oxUBase $oCurrentView
|
||||
* @param array $aParameter
|
||||
@ -540,18 +579,14 @@ class d3_oxcmp_utils_googleanalytics extends d3_oxcmp_utils_googleanalytics_pare
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function _d3getUniversalSendPageViewPageParameter($oCurrentView, $aParameter)
|
||||
protected function _d3getGtagSendPageViewPageParameter($oCurrentView, $aParameter)
|
||||
{
|
||||
if ($oCurrentView->getIsOrderStep() || strtolower($oCurrentView->getClassName()) == 'thankyou') {
|
||||
$aParameter[] = "'page': '/{$oCurrentView->getClassName()}.html'";
|
||||
$aParameter[] = "'title': 'Checkout: " . ucfirst($oCurrentView->getClassName()) . "'";
|
||||
|
||||
return $aParameter;
|
||||
$aParameter[] = "'page_path': '/{$oCurrentView->getClassName()}.html'";
|
||||
$aParameter[] = "'page_title': 'Checkout: " . ucfirst($oCurrentView->getClassName()) . "'";
|
||||
} elseif ($this->_d3HasNoPageParameter()) {
|
||||
$aParameter[] = "'page': '/{$oCurrentView->getClassName()}.html'";
|
||||
$aParameter[] = "'title': '" . ucfirst($oCurrentView->getClassName()) . "'";
|
||||
|
||||
return $aParameter;
|
||||
$aParameter[] = "'page_path': '/{$oCurrentView->getClassName()}.html'";
|
||||
$aParameter[] = "'page_title': '" . ucfirst($oCurrentView->getClassName()) . "'";
|
||||
}
|
||||
|
||||
return $aParameter;
|
||||
|
@ -142,7 +142,8 @@
|
||||
<label for="sD3GAType">[{oxmultilang ident="D3_GOOGLEANALYTICS_MAIN_GATYPE"}]</label>
|
||||
</dt>
|
||||
<dd>
|
||||
<input type="radio" name="value[sD3GAType]" value="universal" [{if $oView->getGaType() != 'async'}]checked[{/if}] onclick="alert('[{oxmultilang ident="D3_GOOGLEANALYTICS_MAIN_GATYPE_UNIVERSAL_DESC"}]');"> [{oxmultilang ident="D3_GOOGLEANALYTICS_MAIN_GATYPE_UNIVERSAL"}]<br>
|
||||
<input type="radio" name="value[sD3GAType]" value="gtag" [{if $oView->getGaType() == 'gtag'}]checked[{/if}]> [{oxmultilang ident="D3_GOOGLEANALYTICS_MAIN_GATYPE_GTAG"}]<br>
|
||||
<input type="radio" name="value[sD3GAType]" value="universal" [{if $oView->getGaType() == 'universal'}]checked[{/if}] onclick="alert('[{oxmultilang ident="D3_GOOGLEANALYTICS_MAIN_GATYPE_UNIVERSAL_DESC"}]');"> [{oxmultilang ident="D3_GOOGLEANALYTICS_MAIN_GATYPE_UNIVERSAL"}]<br>
|
||||
<input type="radio" name="value[sD3GAType]" value="async" [{if $oView->getGaType() == 'async'}]checked[{/if}] onclick="alert('[{oxmultilang ident="D3_GOOGLEANALYTICS_MAIN_GATYPE_ASYNC_DESC"}]');"> [{oxmultilang ident="D3_GOOGLEANALYTICS_MAIN_GATYPE_ASYNC"}]
|
||||
[{oxinputhelp ident="D3_GOOGLEANALYTICS_MAIN_GATYPE_DESC"}]
|
||||
</dd>
|
||||
|
@ -0,0 +1,354 @@
|
||||
[{if $blD3GoogleAnalyticsActive && $oD3GASettings->getValue('sD3GAId')}]
|
||||
[{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;
|
||||
if (document.cookie.indexOf(disableStr + '=true') > -1) {
|
||||
window[disableStr] = true;
|
||||
}
|
||||
|
||||
function gaOptout() {
|
||||
document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
|
||||
window[disableStr] = true;
|
||||
}
|
||||
</script>
|
||||
[{/block}]
|
||||
[{/if}]
|
||||
|
||||
## nach head ## https://developers.google.com/analytics/devguides/collection/gtagjs/
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_MEASUREMENT_ID"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
|
||||
## https://developers.google.com/analytics/devguides/collection/gtagjs/setting-values
|
||||
gtag('set', {
|
||||
'currency': 'USD',
|
||||
'country': 'US'
|
||||
});
|
||||
|
||||
gtag(
|
||||
'config', 'GA_MEASUREMENT_ID',
|
||||
{
|
||||
## https://developers.google.com/analytics/devguides/collection/gtagjs/pages
|
||||
'page_title' : 'homepage',
|
||||
'page_path': '/home',
|
||||
|
||||
## https://developers.google.com/analytics/devguides/collection/gtagjs/cookies-user-id
|
||||
'cookie_prefix': 'MyCookie',
|
||||
'cookie_domain': 'blog.example.com',
|
||||
'cookie_expires': 28 * 24 * 60 * 60 // 28 days, in seconds
|
||||
|
||||
## https://developers.google.com/analytics/devguides/collection/gtagjs/cookies-user-id !!! Anonymize
|
||||
'user_id': 'USER_ID'
|
||||
|
||||
## https://developers.google.com/analytics/devguides/collection/gtagjs/cross-domain
|
||||
'linker': { 'domains': ['example-1.com', 'example-2.com'] }
|
||||
## https://developers.google.com/analytics/devguides/collection/gtagjs/cross-domain
|
||||
'linker': { 'accept_incoming': true }
|
||||
|
||||
## https://developers.google.com/analytics/devguides/collection/gtagjs/custom-dims-mets
|
||||
## siehe auch Event
|
||||
'custom_map': {'dimension2': 'age'}
|
||||
|
||||
## https://developers.google.com/analytics/devguides/collection/gtagjs/ip-anonymization
|
||||
'anonymize_ip': true
|
||||
}
|
||||
);
|
||||
|
||||
## https://developers.google.com/analytics/devguides/collection/gtagjs/
|
||||
gtag('config', 'GA_MEASUREMENT_ID_2');
|
||||
|
||||
## https://developers.google.com/gtagjs/devguide/snippet
|
||||
gtag('config', 'AW-CONVERSION_ID');
|
||||
|
||||
## https://developers.google.com/gtagjs/devguide/snippet
|
||||
gtag('config', 'DC-FLOODLIGHT_ID');
|
||||
|
||||
## https://developers.google.com/analytics/devguides/collection/gtagjs/events
|
||||
gtag('event', <action>, { 'event_category': <category>, 'event_label': <label>, 'value': <value> });
|
||||
|
||||
## https://developers.google.com/analytics/devguides/collection/gtagjs/user-timings
|
||||
// Feature detects Navigation Timing API support.
|
||||
if (window.performance) {
|
||||
// Gets the number of milliseconds since page load
|
||||
// (and rounds the result since the value must be an integer).
|
||||
var timeSincePageLoad = Math.round(performance.now());
|
||||
|
||||
// Sends the timing event to Google Analytics.
|
||||
gtag('event', 'timing_complete', {
|
||||
'name': 'load',
|
||||
'value': timeSincePageLoad,
|
||||
'event_category': 'JS Dependencies'
|
||||
});
|
||||
}
|
||||
|
||||
## https://developers.google.com/analytics/devguides/collection/gtagjs/exceptions
|
||||
gtag('event', 'exception', {
|
||||
'description': 'error_description',
|
||||
'fatal': false // set to true if the error is fatal
|
||||
});
|
||||
|
||||
## https://developers.google.com/analytics/devguides/collection/gtagjs/custom-dims-mets
|
||||
gtag ('event', 'age_dimension', {'age': 12});
|
||||
|
||||
## https://developers.google.com/analytics/devguides/collection/gtagjs/ecommerce
|
||||
## https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce
|
||||
gtag('event', 'purchase', {
|
||||
"transaction_id": "24.031608523954162",
|
||||
"affiliation": "Google online store",
|
||||
"value": 23.07,
|
||||
"currency": "USD",
|
||||
"tax": 1.24,
|
||||
"shipping": 0,
|
||||
"items": [
|
||||
{
|
||||
"id": "P12345",
|
||||
"name": "Android Warhol T-Shirt",
|
||||
"list_name": "Search Results",
|
||||
"brand": "Google",
|
||||
"category": "Apparel/T-Shirts",
|
||||
"variant": "Black",
|
||||
"list_position": 1,
|
||||
"quantity": 2,
|
||||
"price": '2.0'
|
||||
},
|
||||
{
|
||||
"id": "P67890",
|
||||
"name": "Flame challenge TShirt",
|
||||
"list_name": "Search Results",
|
||||
"brand": "MyBrand",
|
||||
"category": "Apparel/T-Shirts",
|
||||
"variant": "Red",
|
||||
"list_position": 2,
|
||||
"quantity": 1,
|
||||
"price": '3.0'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
## https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce
|
||||
gtag('event', 'view_item_list', {
|
||||
"items": [
|
||||
{
|
||||
"id": "P12345",
|
||||
"name": "Android Warhol T-Shirt",
|
||||
"list_name": "Search Results",
|
||||
"brand": "Google",
|
||||
"category": "Apparel/T-Shirts",
|
||||
"variant": "Black",
|
||||
"list_position": 1,
|
||||
"quantity": 2,
|
||||
"price": 2
|
||||
},
|
||||
{
|
||||
"id": "P67890",
|
||||
"name": "Flame challenge TShirt",
|
||||
"list_name": "Search Results",
|
||||
"brand": "MyBrand",
|
||||
"category": "Apparel/T-Shirts",
|
||||
"variant": "Red",
|
||||
"list_position": 2,
|
||||
"quantity": 1,
|
||||
"price": 3
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
## https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce
|
||||
gtag('event', 'view_item', {
|
||||
"items": [
|
||||
{
|
||||
"id": "P12345",
|
||||
"name": "Android Warhol T-Shirt",
|
||||
"list_name": "Search Results",
|
||||
"brand": "Google",
|
||||
"category": "Apparel/T-Shirts",
|
||||
"variant": "Black",
|
||||
"list_position": 1,
|
||||
"quantity": 2,
|
||||
"price": '2.0'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
## https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce
|
||||
gtag('event', 'add_to_cart', {
|
||||
"items": [
|
||||
{
|
||||
"id": "P12345",
|
||||
"name": "Android Warhol T-Shirt",
|
||||
"list_name": "Search Results",
|
||||
"brand": "Google",
|
||||
"category": "Apparel/T-Shirts",
|
||||
"variant": "Black",
|
||||
"list_position": 1,
|
||||
"quantity": 2,
|
||||
"price": '2.0'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
## https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce
|
||||
gtag('event', 'remove_from_cart', {
|
||||
"items": [
|
||||
{
|
||||
"id": "P12345",
|
||||
"name": "Android Warhol T-Shirt",
|
||||
"list_name": "Search Results",
|
||||
"brand": "Google",
|
||||
"category": "Apparel/T-Shirts",
|
||||
"variant": "Black",
|
||||
"list_position": 1,
|
||||
"quantity": 2,
|
||||
"price": '2.0'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
## https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce
|
||||
gtag('event', 'begin_checkout', {
|
||||
"items": [
|
||||
{
|
||||
"id": "P12345",
|
||||
"name": "Android Warhol T-Shirt",
|
||||
"list_name": "Search Results",
|
||||
"brand": "Google",
|
||||
"category": "Apparel/T-Shirts",
|
||||
"variant": "Black",
|
||||
"list_position": 1,
|
||||
"quantity": 2,
|
||||
"price": '2.0'
|
||||
}
|
||||
],
|
||||
"coupon": ""
|
||||
});
|
||||
|
||||
## https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce
|
||||
gtag('event', 'checkout_progress', {
|
||||
"items": [
|
||||
{
|
||||
"id": "P12345",
|
||||
"name": "Android Warhol T-Shirt",
|
||||
"list_name": "Search Results",
|
||||
"brand": "Google",
|
||||
"category": "Apparel/T-Shirts",
|
||||
"variant": "Black",
|
||||
"list_position": 1,
|
||||
"quantity": 2,
|
||||
"price": '2.0'
|
||||
}
|
||||
],
|
||||
"coupon": "SUMMER_DISCOUNT"
|
||||
});
|
||||
|
||||
## https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce
|
||||
gtag('event', 'set_checkout_option', {
|
||||
"checkout_step": 1,
|
||||
"checkout_option": "shipping method",
|
||||
"value": "USPS"
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
---------------------------------------------------------------------
|
||||
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=[{$oD3GASettings->getValue('sD3GAId')}]"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', '[{$oD3GASettings->getValue('sD3GAId')}]' [{$sD3GACreateParameter}]);
|
||||
|
||||
[{include file="d3ga_gtag_ecommerce.tpl"}]
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
(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', '[{$oD3GASettings->getValue('sD3GAId')}]', '[{$sD3CurrentShopUrl}]' [{$sD3GACreateParameter}]);
|
||||
|
||||
[{if $oD3GASettings->getValue('blD3GAAllowDomainLinker')}]
|
||||
ga('require', 'linker');
|
||||
ga('linker:autoLink', [[{$sAFEGetMoreUrls}]]);
|
||||
[{/if}]
|
||||
|
||||
[{include file="d3ga_universal_adwords.tpl"}]
|
||||
|
||||
[{include file="d3ga_universal_custom.tpl"}]
|
||||
|
||||
[{if $oD3GASettings->getValue('blD3GAUseRemarketing')}]
|
||||
ga('require', 'displayfeatures');
|
||||
[{/if}]
|
||||
|
||||
[{* bounce optimization*}]
|
||||
[{block name="d3ga_bounceoptimization"}]
|
||||
[{if $oD3GASettings->getValue('blUseBounceRateOptimization')}]
|
||||
setTimeout('ga(\'send\', \'event\', \'NoBounce\', \'Over defined seconds\')',[{$iD3GASendNoBounceEventTime}]);
|
||||
|
||||
[{if $oD3GASettings->getValue('blSendNoBounceEventScroll')}]
|
||||
window.addEventListener ?
|
||||
window.addEventListener('scroll', testScroll, false) :
|
||||
window.attachEvent('onscroll', testScroll);
|
||||
|
||||
var scrollCount = 0;
|
||||
function testScroll() {
|
||||
++scrollCount;
|
||||
if (scrollCount == 2) {
|
||||
ga('send', 'event', 'window', 'scrolled');
|
||||
}
|
||||
}
|
||||
[{/if}]
|
||||
[{/if}]
|
||||
[{/block}]
|
||||
|
||||
ga('send', 'pageview' [{$sD3GASendPageViewParameter}]);
|
||||
|
||||
[{*[{include file="d3ga_universal_ecommerce.tpl"}]*}]
|
||||
|
||||
[{if $oD3GASettings->getValue('blD3GATrackPageLoadTime')}]
|
||||
[{block name="d3ga_trackpageloadtime"}]
|
||||
var perfData = window.performance.timing;
|
||||
var pageLoadTime =
|
||||
Math.round(
|
||||
(
|
||||
(perfData.domComplete > 0 ? perfData.domComplete : perfData.responseEnd) - perfData.navigationStart
|
||||
) / 1000
|
||||
);
|
||||
|
||||
ga('set', 'metric1', pageLoadTime);
|
||||
[{*ga('send', 'event', 'Page Load Time', loadTime, {'nonInteraction': true});*}]
|
||||
[{/block}]
|
||||
[{/if}]
|
||||
</script>
|
||||
|
||||
[{/strip}]
|
||||
[{/capture}]
|
||||
|
||||
[{if $oViewConf->getActiveClassName() == 'thankyou'}]
|
||||
[{$oView->logCode($smarty.capture.d3GATrackCode)}]
|
||||
[{/if}]
|
||||
|
||||
[{$smarty.capture.d3GATrackCode}]
|
||||
[{/if}]
|
@ -0,0 +1,46 @@
|
||||
[{if $oD3GASettings->getValue('blD3GASendECommerce') && $oViewConf->getActiveClassName() == 'thankyou'}][{strip}]
|
||||
[{block name="UniversalEcommerceOrder"}]
|
||||
[{assign var="order" value=$oView->getOrder()}]
|
||||
|
||||
[{assign var="currate" value=$order->oxorder__oxcurrate->value}]
|
||||
[{if $oD3GASettings->getValue('blD3GAUseNetto')}]
|
||||
[{math equation="s / r" s=$order->getOrderNetSum() r=$currate format="%.2f" assign="sTotal"}] [{* // total - required - has to be gross sum *}]
|
||||
[{else}]
|
||||
[{math equation="s / r" s=$order->getTotalOrderSum() r=$currate format="%.2f" assign="sTotal"}] [{* // total - required *}]
|
||||
[{/if}]
|
||||
[{math equation="s - r" s=$order->getTotalOrderSum() r=$order->getOrderNetSum() format="%.2f" assign="sTax"}]
|
||||
[{math equation="s / r" s=$order->oxorder__oxdelcost->value r=$currate format="%.2f" assign="sShipping"}]
|
||||
|
||||
gtag('event', 'purchase', {
|
||||
"transaction_id": "[{$order->oxorder__oxordernr->value}]",
|
||||
"affiliation": "[{$oxcmp_shop->oxshops__oxname->value|escape:"quotes"}]",
|
||||
"value": [{$sTotal}],
|
||||
"currency": "[{$order->getFieldData('oxcurrency')}]",
|
||||
"tax": [{$sTax}],
|
||||
"shipping": [{$sShipping}],
|
||||
"items": [
|
||||
|
||||
[{foreach from=$order->getOrderArticles() item=oOrderArticle name="artList"}]
|
||||
[{block name="UniversalEcommerceOrderArticle"}]
|
||||
[{if $oD3GASettings->getValue('blD3GAUseNetto')}]
|
||||
[{assign var="oPrice" value=$oOrderArticle->getPrice()}]
|
||||
[{math equation="s / r" s=$oPrice->getNettoPrice() r=$currate format="%.2f" assign="sPrice"}]
|
||||
[{else}]
|
||||
[{assign var="sPrice" value=$oOrderArticle->oxorderarticles__oxprice->value}]
|
||||
[{/if}]
|
||||
{
|
||||
"id": "[{$order->oxorder__oxordernr->value}]",
|
||||
"name": "[{$oOrderArticle->oxorderarticles__oxtitle->value|escape:"quotes"}]",
|
||||
"list_name": "Search Results",
|
||||
"brand": "Google",
|
||||
"category": "[{$oOrderArticle->oxorderarticles__d3_galocator->value|escape:"quotes"}]",
|
||||
"variant": "[{$oOrderArticle->oxorderarticles__oxselvariant->value}]",
|
||||
"list_position": [{$smarty.foreach.artList.index}],
|
||||
"quantity": [{$oOrderArticle->oxorderarticles__oxamount->value}],
|
||||
"price": '[{$sPrice}]'
|
||||
},
|
||||
[{/block}]
|
||||
[{/foreach}]
|
||||
});
|
||||
[{/block}]
|
||||
[{/strip}][{/if}]
|
Loading…
Reference in New Issue
Block a user