From 5b4bd5a05a302554dface746f080e087f8510162 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Thu, 1 Dec 2022 13:29:35 +0100 Subject: [PATCH 01/29] add purchase.tpl content --- Application/views/ga4/purchase.tpl | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Application/views/ga4/purchase.tpl b/Application/views/ga4/purchase.tpl index e69de29..f4f1e29 100755 --- a/Application/views/ga4/purchase.tpl +++ b/Application/views/ga4/purchase.tpl @@ -0,0 +1,36 @@ +[{strip}] + +[{/strip}] \ No newline at end of file From f0466493b31972f986ed34df92022ef47cebf033 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Thu, 1 Dec 2022 13:30:09 +0100 Subject: [PATCH 02/29] rework code to actually fit 6.0.x && 6.1x --- Application/Extend/ViewConfig.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Application/Extend/ViewConfig.php b/Application/Extend/ViewConfig.php index 15b2ecd..141dac2 100755 --- a/Application/Extend/ViewConfig.php +++ b/Application/Extend/ViewConfig.php @@ -30,10 +30,7 @@ class ViewConfig extends ViewConfig_parent { if ($this->sContainerId === null) { - $this->sContainerId = ContainerFactory::getInstance() - ->getContainer() - ->get(ModuleSettingBridgeInterface::class) - ->get('vt_gtm_sContainerID', 'vt-gtm'); + $this->sContainerId = $this->getConfig()->getConfigParam('vt_gtm_sContainerID'); } return $this->sContainerId; } @@ -44,10 +41,7 @@ class ViewConfig extends ViewConfig_parent { if ($this->blGA4enabled === null) { - $this->sContainerId = ContainerFactory::getInstance() - ->getContainer() - ->get(ModuleSettingBridgeInterface::class) - ->get('vt_gtm_blEnableGA4', 'vt-gtm'); + $this->sContainerId = $this->getConfig()->getConfigParam('vt_gtm_blEnableGA4'); } return $this->blGA4enabled; @@ -87,7 +81,7 @@ class ViewConfig extends ViewConfig_parent //'httpref' => $_SERVER["HTTP_REFERER"] ?? "unknown" ]; - return json_encode([$dataLayer], JSON_PRETTY_PRINT); + #return json_encode([$dataLayer], JSON_PRETTY_PRINT); unset($dataLayer["user"]["http"]); // das brauchen wir hier nicht From 5de90a24880fc52501d191e74631b6da32110990 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Thu, 1 Dec 2022 13:53:16 +0100 Subject: [PATCH 03/29] config composer.json to fit ce-metapackage 6.0 - 6.1 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ddaaa31..c89d86b 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ }, "require": { "php": ">=7.1", - "oxid-esales/oxideshop-ce": "^v6.2", + "oxid-esales/oxideshop-ce": "v6.0.* - 6.3.*", "google/apiclient":" ^2.0" }, "autoload": { From 4c08f58777634a79910b7d8b421b8814de6fe692 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Thu, 1 Dec 2022 13:57:52 +0100 Subject: [PATCH 04/29] fix typo in composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c89d86b..01488f1 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ }, "require": { "php": ">=7.1", - "oxid-esales/oxideshop-ce": "v6.0.* - 6.3.*", + "oxid-esales/oxideshop-ce": "v6.0 - 6.3", "google/apiclient":" ^2.0" }, "autoload": { From 6bfe8b90e68ae9689e2dd74f939c852aa932ea24 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Tue, 20 Dec 2022 11:52:25 +0100 Subject: [PATCH 05/29] add translations + add currency --- Application/views/admin/de/module_options.php | 10 +++++++--- Application/views/blocks/checkout_s5.tpl | 4 ++-- metadata.php | 7 ++++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Application/views/admin/de/module_options.php b/Application/views/admin/de/module_options.php index dffc84e..fcee85c 100755 --- a/Application/views/admin/de/module_options.php +++ b/Application/views/admin/de/module_options.php @@ -24,8 +24,12 @@ input.confinput {position:fixed;top:20px;right:70px;background:#008B2D;padding:1 input.confinput:hover {outline:3px solid #ff3600;} '; $aLang = [ - 'charset' => 'UTF-8', - 'SHOP_MODULE_GROUP_vt_gtm_settings' => $style . 'Einstellungen', + 'charset' => 'UTF-8', 'SHOP_MODULE_vt_gtm_sContainerID' => 'Container ID', - 'SHOP_MODULE_vt_gtm_promotionlistids' => 'Promotion Produktlisten IDs
Weitere Infos zu dieser Einstellung: Modui-Wiki
', + 'SHOP_MODULE_GROUP_vt_gtm_settings' => 'Einstellungen', + 'SHOP_MODULE_vt_gtm_blGA4enab' => 'GA4 Aktivieren', + 'SHOP_MODULE_vt_gtm_blUAenabled' => 'UA Aktivieren', + 'SHOP_MODULE_vt_gtm_sMpapisecret' => 'Map ist Geheim??', + 'SHOP_MODULE_vt_gtm_aPromotionlistIDs' => 'Promotion Produktlisten IDs
Weitere Infos zu dieser Einstellung: Modui-Wiki
', + 'SHOP_MODULE_vt_gtm_blEnableDebug' => 'Debug-Modus aktivieren', ]; diff --git a/Application/views/blocks/checkout_s5.tpl b/Application/views/blocks/checkout_s5.tpl index 3129ac6..87c1e19 100644 --- a/Application/views/blocks/checkout_s5.tpl +++ b/Application/views/blocks/checkout_s5.tpl @@ -14,8 +14,8 @@ 'affiliation':'[{$oxcmp_shop->oxshops__oxname->value}]', 'revenue':'[{$_gtmOrder->oxorder__oxtotalordersum->value}]', 'tax':'[{math equation="x+y" x=$_gtmOrder->oxorder__oxartvatprice1->value y=$_gtmOrder->oxorder__oxartvatprice2->value }]', - 'shipping':'[{$_gtmOrder->oxorder__oxdelcost->value}]' - /*'coupon':'CANO25' //if a coupon code was used for this order*/ + 'shipping':'[{$_gtmOrder->oxorder__oxdelcost->value}]', + 'currency': "[{$_gtmOrder->getFieldData('oxcurrency')}]" }, 'products':[ [{foreach from=$_gtmArticles item="_gtmArticle" name="gtmArticles"}] diff --git a/metadata.php b/metadata.php index 8dee4b4..dbb9814 100755 --- a/metadata.php +++ b/metadata.php @@ -129,7 +129,7 @@ $aModule = [ ], [ 'group' => 'vt_gtm_settings', - 'name' => 'vt_gtm_blGA4enabled', + 'name' => 'vt_gtm_blGA4enab', 'type' => 'bool', 'value' => true, 'position' => 1 @@ -141,13 +141,14 @@ $aModule = [ 'value' => true, 'position' => 2 ], - [ + /*[ + I have no idea what this is 'group' => 'vt_gtm_settings', 'name' => 'vt_gtm_sMpapisecret', 'type' => 'str', 'value' => '', 'position' => 3 - ], + ],*/ [ 'group' => 'vt_gtm_settings', 'name' => 'vt_gtm_aPromotionlistIDs', From 76e7bd10f69315e23d265a7798f237427fd2e9a6 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Tue, 10 Jan 2023 09:54:34 +0100 Subject: [PATCH 06/29] switching event names to recommendation form google --- Application/views/blocks/checkout_s1.tpl | 2 +- Application/views/blocks/checkout_s5.tpl | 2 +- Application/views/blocks/detail.tpl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Application/views/blocks/checkout_s1.tpl b/Application/views/blocks/checkout_s1.tpl index 26d293a..9123e19 100644 --- a/Application/views/blocks/checkout_s1.tpl +++ b/Application/views/blocks/checkout_s1.tpl @@ -3,7 +3,7 @@ [{/strip}] [{/if}] \ No newline at end of file diff --git a/metadata.php b/metadata.php index dbb9814..dd419b2 100755 --- a/metadata.php +++ b/metadata.php @@ -117,6 +117,13 @@ $aModule = [ 'template' => 'page/checkout/thankyou.tpl', 'block' => 'checkout_thankyou_main', 'file' => '/Application/views/blocks/checkout_s5.tpl' + ], + // Lists + // view_item_list + [ + 'template' => 'widget/product/list.tpl', + 'block' => 'd3Ga4_view_item_list', + 'file' => '/Application/views/ga4/view_item_list.tpl' ] ], 'settings' => [ From 6b039b6c9a6c2bdf83cc936f76744c53755245e6 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Tue, 10 Jan 2023 15:49:54 +0100 Subject: [PATCH 08/29] add view_search_result --- Application/views/ga4/search.tpl | 32 ++++++++++++++++++++++++++++++++ metadata.php | 6 ++++++ 2 files changed, 38 insertions(+) diff --git a/Application/views/ga4/search.tpl b/Application/views/ga4/search.tpl index e69de29..d71f6ea 100755 --- a/Application/views/ga4/search.tpl +++ b/Application/views/ga4/search.tpl @@ -0,0 +1,32 @@ +[{$smarty.block.parent}] + +[{assign var="gtmProducts" value=$oView->getArticleList()}] + +[{if $gtmProducts|@count}] + [{strip}] + + [{/strip}] +[{/if}] \ No newline at end of file diff --git a/metadata.php b/metadata.php index dd419b2..1d59119 100755 --- a/metadata.php +++ b/metadata.php @@ -124,6 +124,12 @@ $aModule = [ 'template' => 'widget/product/list.tpl', 'block' => 'd3Ga4_view_item_list', 'file' => '/Application/views/ga4/view_item_list.tpl' + ], + // view_search_result + [ + 'template' => 'page/search/search.tpl', + 'block' => 'search_results', + 'file' => '/Application/views/ga4/search.tpl' ] ], 'settings' => [ From 95de52600db134001e2015079e5815c4d399e67f Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Wed, 11 Jan 2023 14:43:13 +0100 Subject: [PATCH 09/29] add add_to_cart --- Application/views/ga4/add_to_cart.tpl | 79 ++++++++++++++++----------- metadata.php | 6 ++ 2 files changed, 54 insertions(+), 31 deletions(-) diff --git a/Application/views/ga4/add_to_cart.tpl b/Application/views/ga4/add_to_cart.tpl index a3d5e3a..37316b1 100644 --- a/Application/views/ga4/add_to_cart.tpl +++ b/Application/views/ga4/add_to_cart.tpl @@ -1,41 +1,58 @@ -[{strip}] - [{$gtmProduct|@var_dump}] - [{* variable $gtmProduct is passed from parent tempalte *}] - [{* - [{assign var="gtmCurrency" value=$oView->getActCurrency()}] - [{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}] - [{assign var="gtmCategory" value=$gtmProduct->getCategory()}] - - *}] [{/strip}] \ No newline at end of file diff --git a/metadata.php b/metadata.php index 1d59119..574fd2a 100755 --- a/metadata.php +++ b/metadata.php @@ -130,6 +130,12 @@ $aModule = [ 'template' => 'page/search/search.tpl', 'block' => 'search_results', 'file' => '/Application/views/ga4/search.tpl' + ], + // add_to_cart + [ + 'template' => 'page/details/inc/productmain.tpl', + 'block' => 'details_productmain_tobasket', + 'file' => '/Application/views/ga4/add_to_cart.tpl' ] ], 'settings' => [ From c83e908da124e2720bcbe56369707128577de267 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Wed, 11 Jan 2023 15:04:41 +0100 Subject: [PATCH 10/29] reworking view_cart to add necessary parameters --- Application/views/blocks/checkout_s1.tpl | 84 ++++++++---------------- 1 file changed, 29 insertions(+), 55 deletions(-) diff --git a/Application/views/blocks/checkout_s1.tpl b/Application/views/blocks/checkout_s1.tpl index 9123e19..d488548 100644 --- a/Application/views/blocks/checkout_s1.tpl +++ b/Application/views/blocks/checkout_s1.tpl @@ -1,57 +1,31 @@ -[{strip}] - [{assign var='gtmCartArticles' value=$oView->getBasketArticles()}] - -[{/strip}] -[{$smarty.block.parent}] \ No newline at end of file +[{assign var='gtmCartArticles' value=$oView->getBasketArticles()}] +[{strip}][{capture assign=d3_ga4_view_cart}] + dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */ + dataLayer.push({ + 'event': 'view_cart', + 'eventLabel':'Checkout Step 1', + 'ecommerce': { + 'actionField': "step: 1", + 'currency': "[{$currency->name}]", + 'value': [{$oxcmp_basket->getBruttoSum()}], + 'items': [ + [{foreach from=$oxcmp_basket->getContents() item=basketitem name=gtmCartContents key=basketindex}] + [{assign var='_price' value=$basketitem->getUnitPrice()}] + { + 'item_id': '[{$gtmCartArticles[$basketindex]->oxarticles__oxartnum->value}]', + 'item_name': '[{$gtmCartArticles[$basketindex]->oxarticles__oxtitle->value}]', + 'item_variant': '[{$gtmCartArticles[$basketindex]->oxarticles__oxvarselect->value}]', + 'price': [{$_price->getPrice()}], + 'quantity':[{$basketitem->getAmount()}], + 'position':[{$smarty.foreach.gtmCartContents.index}] + }[{if !$smarty.foreach.gtmCartContents.last}],[{/if}] + [{/foreach}] + ] + } + }); +[{/capture}][{/strip}] +[{oxscript add=$d3_ga4_view_cart}] \ No newline at end of file From 664119f89e0aac5b440de56e003da6b597458330 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Wed, 11 Jan 2023 15:25:02 +0100 Subject: [PATCH 11/29] genuine reworking structure and aligning all --- Application/views/blocks/checkout_s5.tpl | 42 +++++++++++------------- Application/views/blocks/detail.tpl | 26 +++++++-------- 2 files changed, 32 insertions(+), 36 deletions(-) diff --git a/Application/views/blocks/checkout_s5.tpl b/Application/views/blocks/checkout_s5.tpl index bb66462..96cc2d3 100644 --- a/Application/views/blocks/checkout_s5.tpl +++ b/Application/views/blocks/checkout_s5.tpl @@ -8,30 +8,28 @@ 'event': 'purchase', 'eventLabel':'Checkout Step 5', 'ecommerce': { - 'purchase': { - 'actionField': { - 'id':'[{$_gtmOrder->oxorder__oxordernr->value}]', - 'affiliation':'[{$oxcmp_shop->oxshops__oxname->value}]', - 'revenue':'[{$_gtmOrder->oxorder__oxtotalordersum->value}]', - 'tax':'[{math equation="x+y" x=$_gtmOrder->oxorder__oxartvatprice1->value y=$_gtmOrder->oxorder__oxartvatprice2->value }]', - 'shipping':'[{$_gtmOrder->oxorder__oxdelcost->value}]', - 'currency': "[{$_gtmOrder->getFieldData('oxcurrency')}]" - }, - 'products':[ - [{foreach from=$_gtmArticles item="_gtmArticle" name="gtmArticles"}] - { - 'id':'[{$_gtmArticle->oxorderarticles__oxartnum->value}]', - 'name': '[{$_gtmArticle->oxorderarticles__oxtitle->value}]', - 'variant':'[{$_gtmArticle->oxorderarticles__oxselvariant->value}]', - 'price': [{$_gtmArticle->oxorderarticles__oxprice->value}], - 'quantity':[{$_gtmArticle->oxorderarticles__oxamount->value}], - 'position':[{$smarty.foreach.gtmArticles.iteration}] - }[{if !$smarty.foreach.gtmArticles.last}],[{/if}] - [{/foreach}] - ] + 'transaction_id':'[{$_gtmOrder->oxorder__oxordernr->value}]', + 'affiliation':'[{$oxcmp_shop->oxshops__oxname->value}]', + 'value':'[{$_gtmOrder->oxorder__oxtotalordersum->value}]', + 'tax':'[{math equation="x+y" x=$_gtmOrder->oxorder__oxartvatprice1->value y=$_gtmOrder->oxorder__oxartvatprice2->value }]', + 'shipping':'[{$_gtmOrder->oxorder__oxdelcost->value}]', + 'currency': "[{$_gtmOrder->getFieldData('oxcurrency')}]" + 'items': + [ + [{foreach from=$_gtmArticles item="_gtmArticle" name="gtmArticles"}] + { + 'id':'[{$_gtmArticle->oxorderarticles__oxartnum->value}]', + 'name': '[{$_gtmArticle->oxorderarticles__oxtitle->value}]', + 'variant':'[{$_gtmArticle->oxorderarticles__oxselvariant->value}]', + 'price': [{$_gtmArticle->oxorderarticles__oxprice->value}], + 'quantity':[{$_gtmArticle->oxorderarticles__oxamount->value}], + 'position':[{$smarty.foreach.gtmArticles.iteration}] + }[{if !$smarty.foreach.gtmArticles.last}],[{/if}] + [{/foreach}] + ] } } - }); + }) [{/strip}] [{$smarty.block.parent}] diff --git a/Application/views/blocks/detail.tpl b/Application/views/blocks/detail.tpl index d18bba6..bf4322a 100644 --- a/Application/views/blocks/detail.tpl +++ b/Application/views/blocks/detail.tpl @@ -2,26 +2,24 @@ [{assign var="gtmProduct" value=$oView->getProduct()}] [{assign var="gtmCategory" value=$gtmProduct->getCategory()}] [{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}] -[{strip}][{/strip}] + \ No newline at end of file From 9ae1afa3268831bc7d83bb312da8e0995cbfbf18 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Wed, 11 Jan 2023 15:25:27 +0100 Subject: [PATCH 12/29] reworking structure and add 2 missing mandatory params --- Application/views/ga4/view_item_list.tpl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Application/views/ga4/view_item_list.tpl b/Application/views/ga4/view_item_list.tpl index b2cffbe..ade82d8 100644 --- a/Application/views/ga4/view_item_list.tpl +++ b/Application/views/ga4/view_item_list.tpl @@ -9,6 +9,8 @@ 'event':'view_item_list', 'event_name': 'view_item_list', 'ecommerce': { + 'item_list_id': 'test', + 'item_list_name': 'test', 'items': [ [{foreach from=$gtmProducts name="gtmProducts" item="gtmProduct"}] [{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}] From 2b864f41e8039feec7abd2fd3728ac9cdeef7217 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Wed, 11 Jan 2023 15:31:56 +0100 Subject: [PATCH 13/29] cleaning + rm unnecessary " } " --- Application/views/blocks/checkout_s5.tpl | 28 ++++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Application/views/blocks/checkout_s5.tpl b/Application/views/blocks/checkout_s5.tpl index 96cc2d3..64a8713 100644 --- a/Application/views/blocks/checkout_s5.tpl +++ b/Application/views/blocks/checkout_s5.tpl @@ -1,3 +1,5 @@ +[{$smarty.block.parent}] + [{strip}] [{/strip}] -[{$smarty.block.parent}] From fec7bf5c136ceabb03f2cf89dd3f6a3ddfac3748 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Wed, 11 Jan 2023 15:54:52 +0100 Subject: [PATCH 14/29] add list mandatory params --- Application/views/ga4/view_item_list.tpl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Application/views/ga4/view_item_list.tpl b/Application/views/ga4/view_item_list.tpl index ade82d8..448a397 100644 --- a/Application/views/ga4/view_item_list.tpl +++ b/Application/views/ga4/view_item_list.tpl @@ -1,5 +1,13 @@ [{assign var="gtmProducts" value=$products}] +[{assign var="breadCrumb" value=''}] + +[{foreach from=$oView->getBreadCrumb() item=sCrum}] + [{if $sCrum.title }] + [{$breadCrumb|cat:$sCrum.title|cat:" > "}] + [{/if}] +[{/foreach}] + [{if $gtmProducts|@count}] [{strip}] + + [{$oViewConf->triggerGA4events()}] + [{if $oViewConf->getTopActionClassName() === "alist" }] + [{* include file="ga4_view_item_list.tpl" gtmCategory=$oView->getActiveCategory() gtmProducts=$oView->getArticleList() listtype=$oView->getListType() *}] + [{elseif $oViewConf->getTopActionClassName() === "details" }] + [{* include file="ga4_view_item.tpl" gtmProduct=$oView->getProduct() *}] + [{elseif $oViewConf->getTopActionClassName() === "search" }] + [{elseif $oViewConf->getTopActionClassName() === "basket" }] + + [{/if}] + [{/strip}][{/if}] + [{/if}] +[{else}] + [{if $oViewConf->getGtmContainerId()}][{strip}] + + [{$oViewConf->triggerGA4events()}] [{if $oViewConf->getTopActionClassName() === "alist" }] - [{* include file="ga4_view_item_list.tpl" gtmCategory=$oView->getActiveCategory() gtmProducts=$oView->getArticleList() listtype=$oView->getListType() *}] + [{* include file="ga4_view_item_list.tpl" gtmCategory=$oView->getActiveCategory() gtmProducts=$oView->getArticleList() listtype=$oView->getListType() *}] [{elseif $oViewConf->getTopActionClassName() === "details" }] - [{* include file="ga4_view_item.tpl" gtmProduct=$oView->getProduct() *}] + [{* include file="ga4_view_item.tpl" gtmProduct=$oView->getProduct() *}] [{elseif $oViewConf->getTopActionClassName() === "search" }] [{elseif $oViewConf->getTopActionClassName() === "basket" }] [{/if}] -[{/strip}][{/if}] + [{/strip}][{/if}] +[{/if}] + [{$smarty.block.parent}] diff --git a/metadata.php b/metadata.php index d2f098d..35368ce 100755 --- a/metadata.php +++ b/metadata.php @@ -182,7 +182,20 @@ $aModule = [ 'type' => 'bool', 'value' => false, 'position' => 999 - ] - + ], + [ + 'group' => 'vt_gtm_settings_cookiemanager', + 'name' => 'vt_gtm_settings_hasOwnCookieManager', + 'type' => 'bool', + 'value' => false, + 'position' => 999 + ], + [ + 'group' => 'vt_gtm_settings_cookiemanager', + 'name' => 'vt_gtm_settings_cookieName', + 'type' => 'str', + 'value' => 'example', + 'position' => 999 + ], ] ]; \ No newline at end of file From b861aef8a926bc3c85aad48466f1a1bd5c03d8c4 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Thu, 19 Jan 2023 09:32:38 +0100 Subject: [PATCH 19/29] fix bug that'd stop jquery from running duo to no-datalayer error --- Application/views/blocks/_gtm_js.tpl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Application/views/blocks/_gtm_js.tpl b/Application/views/blocks/_gtm_js.tpl index 981c4a7..0f22c6f 100755 --- a/Application/views/blocks/_gtm_js.tpl +++ b/Application/views/blocks/_gtm_js.tpl @@ -26,6 +26,10 @@ [{/if}] [{/strip}][{/if}] + [{else}] + [{/if}] [{else}] [{if $oViewConf->getGtmContainerId()}][{strip}] From ed75197a6465c5160cf7664746b106d83b487e08 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Thu, 19 Jan 2023 11:37:40 +0100 Subject: [PATCH 20/29] add info to readme --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 2508a71..4d49dd8 100755 --- a/README.md +++ b/README.md @@ -15,6 +15,14 @@ module version 0.5.0 ( 2021-12-10 ) für alle implementierten GA4 Events existieren Templates unter `source/modules/GoogleTagManager/Application/views/ga4/`, dabei entspricht der Dateiname dem Eventnamen in GA4. Die Einbindung dieser Event-Templates erfolgt über TPL-Blöcke unter `source/modules/GoogleTagManager/Application/views/blocks/`. +### aktuell zu beachtende Blöcke +- Suchergebnisse: search_results +- (muss hinzugefügt werden) aList: d3Ga4_view_item_list +- Detailseite: details_productmain_title +- add_to_basket-button: details_productmain_tobasket +- Warenkorb: checkout_basket_main +- Purchase | abgeschlossener Kauf: checkout_thankyou_main + ## Universal Analytics Events **"EE-Trigger" für Ecomemrce-Tags (Beispiel für Google Tag Manager):** From dfab91a71afd1bcfc9ee60a3463b3f80aab5127a Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Thu, 19 Jan 2023 15:31:56 +0100 Subject: [PATCH 21/29] adding missing standard-files; rebranding and moving ViewConfig extension --- .php-cs-fixer.php | 13 + Application/Extend/.ide-helper.php | 5 - CHANGELOG.md | 30 +++ IntelliSenseHelper.php | 18 ++ .../Extend => Modules/Core}/ViewConfig.php | 244 +++++++++--------- README.md | 118 ++++----- __README.md | 67 +++++ composer.json | 30 ++- metadata.php | 32 +-- phpstan.neon | 10 + phpunit.xml | 20 ++ 11 files changed, 377 insertions(+), 210 deletions(-) create mode 100644 .php-cs-fixer.php delete mode 100644 Application/Extend/.ide-helper.php create mode 100644 CHANGELOG.md create mode 100644 IntelliSenseHelper.php rename {Application/Extend => Modules/Core}/ViewConfig.php (96%) mode change 100755 => 100644 mode change 100755 => 100644 README.md create mode 100644 __README.md create mode 100644 phpstan.neon create mode 100644 phpunit.xml diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php new file mode 100644 index 0000000..f0512a0 --- /dev/null +++ b/.php-cs-fixer.php @@ -0,0 +1,13 @@ +in(__DIR__) +; + +$config = new PhpCsFixer\Config(); +return $config->setRules([ + '@PHP73Migration' => true, + '@PSR12' => true + ]) + ->setFinder($finder) +; \ No newline at end of file diff --git a/Application/Extend/.ide-helper.php b/Application/Extend/.ide-helper.php deleted file mode 100644 index 75eb3c4..0000000 --- a/Application/Extend/.ide-helper.php +++ /dev/null @@ -1,5 +0,0 @@ - + * @link http://www.oxidmodule.com + */ + +namespace D3\GoogleAnalytics4\Modules\Core{ + class ViewConfig_parent extends \OxidEsales\Eshop\Core\ViewConfig{} +} \ No newline at end of file diff --git a/Application/Extend/ViewConfig.php b/Modules/Core/ViewConfig.php old mode 100755 new mode 100644 similarity index 96% rename from Application/Extend/ViewConfig.php rename to Modules/Core/ViewConfig.php index 141dac2..ca5cc37 --- a/Application/Extend/ViewConfig.php +++ b/Modules/Core/ViewConfig.php @@ -1,123 +1,123 @@ - - */ - -namespace VanillaThunder\GoogleTagManager\Application\Extend; - -use OxidEsales\Eshop\Application\Controller\FrontendController; -use OxidEsales\Eshop\Core\Registry; -use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory; -use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ModuleSettingBridgeInterface; - -class ViewConfig extends ViewConfig_parent -{ - - // Google Tag Manager Container ID - private $sContainerId = null; - - public function getGtmContainerId() - { - if ($this->sContainerId === null) - { - $this->sContainerId = $this->getConfig()->getConfigParam('vt_gtm_sContainerID'); - } - return $this->sContainerId; - } - - private $blGA4enabled = null; - - public function isGA4enabled() - { - if ($this->blGA4enabled === null) - { - $this->sContainerId = $this->getConfig()->getConfigParam('vt_gtm_blEnableGA4'); - } - - return $this->blGA4enabled; - } - - public function getGtmDataLayer() - { - if (!$this->getGtmContainerId()) return "[]"; - - $oConfig = Registry::getConfig(); - $oView = $oConfig->getTopActiveView(); - /** @var FrontendController $oShop */ - //$oShop = oxRegistry::getConfig()->getActiveShop(); /** @var oxShop $oShop */ - $oUser = $oConfig->getUser(); - - $cl = $this->getTopActionClassName(); - $aPageTypes = [ - "content" => "cms", - "details" => "product", - "alist" => "listing", - "search" => "listing", - "basket" => "checkout", - "user" => "checkout", - "payment" => "checkout", - "order" => "checkout", - "thankyou" => "checkout", - ]; - - $dataLayer = [ - 'page' => [ - 'type' => $aPageTypes[$cl] ?? "unknown", - 'title' => $oView->getTitle(), - 'cl' => $cl, - ], - 'userid' => ($oUser ? $oUser->getId() : false), - 'sessionid' => session_id() ?? false, - //'httpref' => $_SERVER["HTTP_REFERER"] ?? "unknown" - ]; - - #return json_encode([$dataLayer], JSON_PRETTY_PRINT); - - unset($dataLayer["user"]["http"]); // das brauchen wir hier nicht - - - return json_encode([$dataLayer], JSON_PRETTY_PRINT); - /* - // --- Produktdaten --- - $transactionProducts = []; - foreach($oOrder->getOrderArticles() as $_prod ) $transactionProducts[] = [ - 'name' => '', // (erforderlich) Produktname String - 'sku' => '', // (erforderlich) Produkt-SKU String - 'category' => '', // (optional) Produktkategorie String - 'price' => '', // (erforderlich) Preis pro Einheit Numerischer Wert - 'quantity' => '' // (erforderlich) Anzahl der Artikel Numerischer Wert - ]; - - // --- Transaktionsdaten --- - - $dataLayer['transactionId'] = $oOrder->oxorder__oxordernr->value; // (erforderlich) Eindeutige Transaktionskennung String - $dataLayer['transactionAffiliation'] = $oShop->oxshops__oxname->value; // (optional) Partner oder Geschäft String - $dataLayer['transactionTotal'] = $oOrder->oxorder__oxtotalordersum->value; // (erforderlich) Gesamtwert der Transaktion Numerischer Wert - $dataLayer['transactionShipping'] = $oOrder->oxorder__oxdelcost->value; // (optional) Versandkosten für die Transaktion Numerischer Wert - $dataLayer['transactionTax'] = ''; // (optional) Steuerbetrag für die Transaktion Numerischer Wert - $dataLayer['transactionProducts'] = $transactionProducts; // (optional) Liste der bei der Transaktion erworbenen Artikel Array von Produktobjekten - */ - } - - public function triggerGA4events() - { - // general events - - } - - public function isPromotionList($listId) - { - $oConfig = Registry::getConfig(); - $aPromotionListIds = $oConfig->getConfigParam("") ?? ['bargainItems', 'newItems', 'topBox', 'alsoBought', 'accessories', 'cross']; - } + + */ + +namespace D3\GoogleAnalytics4\Modules\Core; + +use OxidEsales\Eshop\Application\Controller\FrontendController; +use OxidEsales\Eshop\Core\Registry; +use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory; +use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ModuleSettingBridgeInterface; + +class ViewConfig extends ViewConfig_parent +{ + + // Google Tag Manager Container ID + private $sContainerId = null; + + public function getGtmContainerId() + { + if ($this->sContainerId === null) + { + $this->sContainerId = $this->getConfig()->getConfigParam('vt_gtm_sContainerID'); + } + return $this->sContainerId; + } + + private $blGA4enabled = null; + + public function isGA4enabled() + { + if ($this->blGA4enabled === null) + { + $this->sContainerId = $this->getConfig()->getConfigParam('vt_gtm_blEnableGA4'); + } + + return $this->blGA4enabled; + } + + public function getGtmDataLayer() + { + if (!$this->getGtmContainerId()) return "[]"; + + $oConfig = Registry::getConfig(); + $oView = $oConfig->getTopActiveView(); + /** @var FrontendController $oShop */ + //$oShop = oxRegistry::getConfig()->getActiveShop(); /** @var oxShop $oShop */ + $oUser = $oConfig->getUser(); + + $cl = $this->getTopActionClassName(); + $aPageTypes = [ + "content" => "cms", + "details" => "product", + "alist" => "listing", + "search" => "listing", + "basket" => "checkout", + "user" => "checkout", + "payment" => "checkout", + "order" => "checkout", + "thankyou" => "checkout", + ]; + + $dataLayer = [ + 'page' => [ + 'type' => $aPageTypes[$cl] ?? "unknown", + 'title' => $oView->getTitle(), + 'cl' => $cl, + ], + 'userid' => ($oUser ? $oUser->getId() : false), + 'sessionid' => session_id() ?? false, + //'httpref' => $_SERVER["HTTP_REFERER"] ?? "unknown" + ]; + + #return json_encode([$dataLayer], JSON_PRETTY_PRINT); + + unset($dataLayer["user"]["http"]); // das brauchen wir hier nicht + + + return json_encode([$dataLayer], JSON_PRETTY_PRINT); + /* + // --- Produktdaten --- + $transactionProducts = []; + foreach($oOrder->getOrderArticles() as $_prod ) $transactionProducts[] = [ + 'name' => '', // (erforderlich) Produktname String + 'sku' => '', // (erforderlich) Produkt-SKU String + 'category' => '', // (optional) Produktkategorie String + 'price' => '', // (erforderlich) Preis pro Einheit Numerischer Wert + 'quantity' => '' // (erforderlich) Anzahl der Artikel Numerischer Wert + ]; + + // --- Transaktionsdaten --- + + $dataLayer['transactionId'] = $oOrder->oxorder__oxordernr->value; // (erforderlich) Eindeutige Transaktionskennung String + $dataLayer['transactionAffiliation'] = $oShop->oxshops__oxname->value; // (optional) Partner oder Geschäft String + $dataLayer['transactionTotal'] = $oOrder->oxorder__oxtotalordersum->value; // (erforderlich) Gesamtwert der Transaktion Numerischer Wert + $dataLayer['transactionShipping'] = $oOrder->oxorder__oxdelcost->value; // (optional) Versandkosten für die Transaktion Numerischer Wert + $dataLayer['transactionTax'] = ''; // (optional) Steuerbetrag für die Transaktion Numerischer Wert + $dataLayer['transactionProducts'] = $transactionProducts; // (optional) Liste der bei der Transaktion erworbenen Artikel Array von Produktobjekten + */ + } + + public function triggerGA4events() + { + // general events + + } + + public function isPromotionList($listId) + { + $oConfig = Registry::getConfig(); + $aPromotionListIds = $oConfig->getConfigParam("") ?? ['bargainItems', 'newItems', 'topBox', 'alsoBought', 'accessories', 'cross']; + } } \ No newline at end of file diff --git a/README.md b/README.md old mode 100755 new mode 100644 index 4d49dd8..d1db9e8 --- a/README.md +++ b/README.md @@ -1,68 +1,70 @@ -# [vt] Google Tag Manager -Google Tag Manager integration for OXID eShop v6.2 und höher -module version 0.5.0 ( 2021-12-10 ) +[![deutsche Version](https://logos.oxidmodule.com/de2_xs.svg)](README.md) + +# ![D3 Logo](https://logos.oxidmodule.com/d3logo_24x24.svg) Google-Analytics 4 für OXID eShop + +Google-Analytics 4 integration via 'Google Tag Manager' für den OXID eShop 6.x + +## Inhaltsverzeichnis + +- [Installation](#installation) +- [Verwendung](#verwendung) +- [Changelog](#changelog) +- [Lizenz](#lizenz) ## Installation -* ``composer require vanilla-thunder/oxid-module-gtm --no-update`` -* Modul aktivieren und Moduleinstellungen konfigurieren -## Tag Manager konfigurieren: -+ https://support.google.com/tagmanager/answer/9442095 +Dieses Paket erfordert einen mit Composer installierten OXID eShop in einer in der [composer.json](composer.json) definierten Version. -## Google Analytics 4 Einrichtung +Bitte tragen Sie den folgenden Abschnitt in die `composer.json` Ihres Projektes ein: -## GA4 Events / Customizing -für alle implementierten GA4 Events existieren Templates unter `source/modules/GoogleTagManager/Application/views/ga4/`, dabei entspricht der Dateiname dem Eventnamen in GA4. -Die Einbindung dieser Event-Templates erfolgt über TPL-Blöcke unter `source/modules/GoogleTagManager/Application/views/blocks/`. +``` + "extra": { + ... + } +``` -### aktuell zu beachtende Blöcke -- Suchergebnisse: search_results -- (muss hinzugefügt werden) aList: d3Ga4_view_item_list -- Detailseite: details_productmain_title -- add_to_basket-button: details_productmain_tobasket -- Warenkorb: checkout_basket_main -- Purchase | abgeschlossener Kauf: checkout_thankyou_main - -## Universal Analytics Events - -**"EE-Trigger" für Ecomemrce-Tags (Beispiel für Google Tag Manager):** -+ Triggertyp: Benutzerdefiniertes Ereignis -+ Ereignisname: ``ee\..*`` -+ Übereinstimmung mit regulärem Ausdruck verwenden -+ Diesen Trigger auslösen bei: Alle benutzerdefinierten Ereignisse - -**"EE-Tag" für Google Analytics Enhanced Ecommerce:** -+ Tag-Typ: Google Analytics - Universal Analytics -+ Tracking-Typ: Ereignis -+ Aktion: {{Event}} -+ Label: {{Event Label}} -+ Trigger : EE-Trigger - -## Verfügbare Datalayer Variablen -Für die einfachste Übersicht der enthaltenen Daten empfehle ich den Vorschau-Modus vom Google Tag Manager. - -Bei jedem Seitenaufruf wird die Datenschicht mit einigen wenigen Infos erstellt, die man zum reinen Erfassen der Seitenaufrufe benötigt: - + **page.type** - Seitentyp: default / cms / product / listing / checkout (an google analytics angelehnt) - + **page.title** - Seitentitel (außer Startseite, sie hat keinen Titel. Danke OXID...) - + **page.cl** - OXID Controller Klasse (start, search, etc) - + **userid** - oxID vom Benutzer bzw `false` falls nicht eingeloggt - + **sessionid** - session iD - -Alle für Ecommerce Tracking releavanten Daten werden mit speziellen Ecommerce Events in die Datenschicht eingefügt. -Hier ist ein Beispiel für die Einrichtung von Enhanced Ecomemrce Tracking über Google Tag Manager: +Öffnen Sie eine Kommandozeile und navigieren Sie zum Stammverzeichnis des Shops (Elternverzeichnis von source und vendor). Führen Sie den folgenden Befehl aus. Passen Sie die Pfadangaben an Ihre Installationsumgebung an. +```bash +php composer require d3/modulename:^2.0 +``` +Sofern nötig, bestätigen Sie bitte, dass Sie `package-name` erlauben, Code auszuführen. -### LICENSE AGREEMENT - [vt] google-tag-manager - Copyright (C) 2021 Marat Bedoev - info: info@mb-dev.pro oder so /** @todo: überarbeiten, wenn ich wieder nüchtern bin */ - - This program is free software; - you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; - either version 3 of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License along with this program; if not, see \ No newline at end of file +Aktivieren Sie das Modul im Shopadmin unter "Erweiterungen -> Module". + +## Verwendung + +... + +## Changelog + +Siehe [CHANGELOG](CHANGELOG.md) für weitere Informationen. + +## Beitragen + +Wenn Sie eine Verbesserungsvorschlag haben, legen Sie einen Fork des Repositories an und erstellen Sie einen Pull Request. Alternativ können Sie einfach ein Issue erstellen. Fügen Sie das Projekt zu Ihren Favoriten hinzu. Vielen Dank. + +- Erstellen Sie einen Fork des Projekts +- Erstellen Sie einen Feature Branch (git checkout -b feature/AmazingFeature) +- Fügen Sie Ihre Änderungen hinzu (git commit -m 'Add some AmazingFeature') +- Übertragen Sie den Branch (git push origin feature/AmazingFeature) +- Öffnen Sie einen Pull Request + +## Lizenz +(Stand: 06.05.2021) + +Vertrieben unter der GPLv3 Lizenz. + +``` +Copyright (c) D3 Data Development (Inh. Thomas Dartsch) + +Diese Software wird unter der GNU GENERAL PUBLIC LICENSE Version 3 vertrieben. +``` + +Die vollständigen Copyright- und Lizenzinformationen entnehmen Sie bitte der [LICENSE](LICENSE.md)-Datei, die mit diesem Quellcode verteilt wurde. + +## weitere Lizenzen und Nutzungsbedingungen + +... \ No newline at end of file diff --git a/__README.md b/__README.md new file mode 100644 index 0000000..dadb102 --- /dev/null +++ b/__README.md @@ -0,0 +1,67 @@ +# [D3] Google Tag Manager +Google Tag Manager integration for OXID eShop v6.x + +## Installation +* ``composer require vanilla-thunder/oxid-module-gtm --no-update`` +* Modul aktivieren und Moduleinstellungen konfigurieren + +## Tag Manager konfigurieren: ++ https://support.google.com/tagmanager/answer/9442095 + +## Google Analytics 4 Einrichtung + +## GA4 Events / Customizing +für alle implementierten GA4 Events existieren Templates unter `source/modules/GoogleTagManager/Application/views/ga4/`, dabei entspricht der Dateiname dem Eventnamen in GA4. +Die Einbindung dieser Event-Templates erfolgt über TPL-Blöcke unter `source/modules/GoogleTagManager/Application/views/blocks/`. + +### aktuell zu beachtende Blöcke +- Suchergebnisse: search_results +- (muss hinzugefügt werden) aList: d3Ga4_view_item_list +- Detailseite: details_productmain_title +- add_to_basket-button: details_productmain_tobasket +- Warenkorb: checkout_basket_main +- Purchase | abgeschlossener Kauf: checkout_thankyou_main + +## Universal Analytics Events + +**"EE-Trigger" für Ecomemrce-Tags (Beispiel für Google Tag Manager):** ++ Triggertyp: Benutzerdefiniertes Ereignis ++ Ereignisname: ``ee\..*`` ++ Übereinstimmung mit regulärem Ausdruck verwenden ++ Diesen Trigger auslösen bei: Alle benutzerdefinierten Ereignisse + +**"EE-Tag" für Google Analytics Enhanced Ecommerce:** ++ Tag-Typ: Google Analytics - Universal Analytics ++ Tracking-Typ: Ereignis ++ Aktion: {{Event}} ++ Label: {{Event Label}} ++ Trigger : EE-Trigger + +## Verfügbare Datalayer Variablen +Für die einfachste Übersicht der enthaltenen Daten empfehle ich den Vorschau-Modus vom Google Tag Manager. + +Bei jedem Seitenaufruf wird die Datenschicht mit einigen wenigen Infos erstellt, die man zum reinen Erfassen der Seitenaufrufe benötigt: + + **page.type** - Seitentyp: default / cms / product / listing / checkout (an google analytics angelehnt) + + **page.title** - Seitentitel (außer Startseite, sie hat keinen Titel. Danke OXID...) + + **page.cl** - OXID Controller Klasse (start, search, etc) + + **userid** - oxID vom Benutzer bzw `false` falls nicht eingeloggt + + **sessionid** - session iD + +Alle für Ecommerce Tracking releavanten Daten werden mit speziellen Ecommerce Events in die Datenschicht eingefügt. +Hier ist ein Beispiel für die Einrichtung von Enhanced Ecomemrce Tracking über Google Tag Manager: + + + + +### LICENSE AGREEMENT + [vt] google-tag-manager + Copyright (C) 2021 Marat Bedoev + info: info@mb-dev.pro oder so /** @todo: überarbeiten, wenn ich wieder nüchtern bin */ + + This program is free software; + you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; + either version 3 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + You should have received a copy of the GNU General Public License along with this program; if not, see \ No newline at end of file diff --git a/composer.json b/composer.json index 01488f1..8de7545 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,20 @@ { - "name": "vanilla-thunder/oxid-module-gtm", - "description": "Google Tag Manager with new Google Analytics 4 for OXID eShop v6.2+
more about GA4: Ecommerce (GA4) Developer Guide", + "name": "d3/google-analytics4", + "description": "Google Tag Manager with new Google Analytics 4 for OXID eShop 6.x", "type": "oxideshop-module", - "homepage": "https://github.com/vanilla-thunder/oxid-module-gtm", + "keywords": [ + "oxid", + "modules", + "eShop", + "d3", + "google", + "ga4", + "googleanalytics", + "gtm", + "configuration", + "license" + ], + "homepage": "https://www.d3data.de", "license": [ "GPL-3.0" ], @@ -10,11 +22,19 @@ { "name": "Marat Bedoev", "email": "hello@mb-dev.pro" + }, + { + "name": "D3 Data Development (Inh. Thomas Dartsch)", + "email": "info@shopmodule.com", + "homepage": "https://www.d3data.de" } ], + "support": { + "email": "support@shopmodule.com" + }, "extra": { "oxideshop": { - "target-directory": "vt/GoogleTagManager" + "target-directory": "d3/googleanalytics" } }, "require": { @@ -24,7 +44,7 @@ }, "autoload": { "psr-4": { - "VanillaThunder\\": "../../../source/modules/vt" + "D3\\GoogleAnalytics4": "../../../source/modules/d3/googleanalytics" } } } \ No newline at end of file diff --git a/metadata.php b/metadata.php index 35368ce..5a001fd 100755 --- a/metadata.php +++ b/metadata.php @@ -1,29 +1,21 @@ - **/ + + +use D3\GoogleAnalytics4\Modules\Core\ViewConfig; +use OxidEsales\Eshop\Core\ViewConfig as OEViewConfig; $sMetadataVersion = '2.1'; $aModule = [ - 'id' => 'vt-gtm', - 'title' => '[vt] Google Tag Manager', - 'description' => 'Google Tag Manager Integration for OXID eShop v6.2+', + 'id' => 'd3googleanalytics4', + 'title' => 'Google Analytics 4', + 'description' => 'Integration erfolgt via GoogleTagmanager und gtags.', 'thumbnail' => 'thumbnail.png', - 'version' => '0.5.0 ( 2021-07-17 )', - 'author' => 'Marat Bedoev', - 'email' => openssl_decrypt("Az6pE7kPbtnTzjHlPhPCa4ktJLphZ/w9gKgo5vA//p4=", str_rot13("nrf-128-pop"), str_rot13("gvalzpr")), - 'url' => 'https://github.com/vanilla-thunder/oxid-module-gtm', + 'version' => '1.0.0.0', + 'author' => 'Data Development (Inh.: Thomas Dartsch)', + 'email' => 'support@shopmodule.com', + 'url' => 'https://www.oxidmodule.com/', 'extend' => [ - \OxidEsales\Eshop\Core\ViewConfig::class => VanillaThunder\GoogleTagManager\Application\Extend\ViewConfig::class + OEViewConfig::class => ViewConfig::class ], 'templates' => [ // GA4 events diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..b6e0779 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,10 @@ +parameters: + scanFiles: + - IntelliSenseHelper.php + - ../../oxid-esales/oxideshop-ce/source/oxfunctions.php + - ../../oxid-esales/oxideshop-ce/source/overridablefunctions.php + level: 9 + phpVersion: 70100 + checkMissingIterableValueType: false + ignoreErrors: + - '#Psr\\Container\\ContainerExceptionInterface is not subtype of Throwable#' diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..516e222 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,20 @@ + + + + + src + + + + + + + ./Tests + + + From f9d7f0b2e938e56d5ee7a4c7bf28d9a2bc24d633 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Thu, 19 Jan 2023 15:36:54 +0100 Subject: [PATCH 22/29] add missing blacklist-filter in composer.json --- composer.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/composer.json b/composer.json index 8de7545..ea310ba 100644 --- a/composer.json +++ b/composer.json @@ -34,6 +34,13 @@ }, "extra": { "oxideshop": { + "blacklist-filter": [ + "*.md", + "composer.json", + ".php-cs-fixer.php", + "*.xml", + "*.neon" + ], "target-directory": "d3/googleanalytics" } }, From 87ce3efc5ff471cd9dc88a95bda7fd440541a129 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Fri, 20 Jan 2023 09:33:21 +0100 Subject: [PATCH 23/29] rm unnecessary files --- Application/views/ua/impression.tpl | 29 ------------- Application/views/ua/s1_cart.tpl | 62 ---------------------------- Application/views/ua/s2_user.tpl | 13 ------ Application/views/ua/s3_payment.tpl | 8 ---- Application/views/ua/s4_order.tpl | 8 ---- Application/views/ua/s5_thankyou.tpl | 44 -------------------- 6 files changed, 164 deletions(-) delete mode 100644 Application/views/ua/impression.tpl delete mode 100644 Application/views/ua/s1_cart.tpl delete mode 100644 Application/views/ua/s2_user.tpl delete mode 100644 Application/views/ua/s3_payment.tpl delete mode 100644 Application/views/ua/s4_order.tpl delete mode 100644 Application/views/ua/s5_thankyou.tpl diff --git a/Application/views/ua/impression.tpl b/Application/views/ua/impression.tpl deleted file mode 100644 index 09dcacc..0000000 --- a/Application/views/ua/impression.tpl +++ /dev/null @@ -1,29 +0,0 @@ -[{strip}] - [{assign var="gtmCategory" value=$gtmProduct->getCategory()}] - [{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}] - -[{/strip}] diff --git a/Application/views/ua/s1_cart.tpl b/Application/views/ua/s1_cart.tpl deleted file mode 100644 index d590b9f..0000000 --- a/Application/views/ua/s1_cart.tpl +++ /dev/null @@ -1,62 +0,0 @@ -[{strip}] - [{assign var="gtmCartArticles" value=$oView->getBasketArticles()}] - -[{/strip}] -[{$smarty.block.parent}] \ No newline at end of file diff --git a/Application/views/ua/s2_user.tpl b/Application/views/ua/s2_user.tpl deleted file mode 100644 index 989f980..0000000 --- a/Application/views/ua/s2_user.tpl +++ /dev/null @@ -1,13 +0,0 @@ - -[{$smarty.block.parent}] \ No newline at end of file diff --git a/Application/views/ua/s3_payment.tpl b/Application/views/ua/s3_payment.tpl deleted file mode 100644 index 6a36e93..0000000 --- a/Application/views/ua/s3_payment.tpl +++ /dev/null @@ -1,8 +0,0 @@ - -[{$smarty.block.parent}] \ No newline at end of file diff --git a/Application/views/ua/s4_order.tpl b/Application/views/ua/s4_order.tpl deleted file mode 100644 index d1c3222..0000000 --- a/Application/views/ua/s4_order.tpl +++ /dev/null @@ -1,8 +0,0 @@ - -[{$smarty.block.parent}] \ No newline at end of file diff --git a/Application/views/ua/s5_thankyou.tpl b/Application/views/ua/s5_thankyou.tpl deleted file mode 100644 index 2523682..0000000 --- a/Application/views/ua/s5_thankyou.tpl +++ /dev/null @@ -1,44 +0,0 @@ - -[{$smarty.block.parent}] From c7d8fdcf6aff1dba9958969a0371a6584453d49e Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Fri, 20 Jan 2023 09:33:36 +0100 Subject: [PATCH 24/29] extend readme and metadata-desc --- README.md | 34 +++++++++++++++++++++++++++++----- metadata.php | 8 +++++++- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d1db9e8..739f257 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,10 @@ # ![D3 Logo](https://logos.oxidmodule.com/d3logo_24x24.svg) Google-Analytics 4 für OXID eShop -Google-Analytics 4 integration via 'Google Tag Manager' für den OXID eShop 6.x +Dieses Modul bietet die Möglichkeit in Ihrem OXID eShop (6.x) die neue 'Property' Google Analytics 4 (GA4) von Google +zu integrieren. +Hierfür stehen Ihnen verschiedene 'templates' zur verfügung, mit denen Sie bestimmte Events tracken können. +Beispiele dafür sind: view_item, add_to_basket, purchase, ... ## Inhaltsverzeichnis @@ -19,7 +22,15 @@ Bitte tragen Sie den folgenden Abschnitt in die `composer.json` Ihres Projektes ``` "extra": { - ... + "oxideshop": { + "blacklist-filter": [ + "*.md", + "composer.json", + ".php-cs-fixer.php", + "*.xml", + "*.neon" + ], + "target-directory": "d3/googleanalytics" } ``` @@ -27,7 +38,7 @@ Bitte tragen Sie den folgenden Abschnitt in die `composer.json` Ihres Projektes ```bash -php composer require d3/modulename:^2.0 +php composer require d3/google-analytics4:^1 ``` Sofern nötig, bestätigen Sie bitte, dass Sie `package-name` erlauben, Code auszuführen. @@ -36,7 +47,20 @@ Aktivieren Sie das Modul im Shopadmin unter "Erweiterungen -> Module". ## Verwendung -... +Nach erfolgreicher Installation finden Sie in Ihrem Shop-Admin unter "Erweiterungen > Module" +den Eintrag 'Google Analytics 4'. +Aktivieren Sie dieses Modul, um die Funktionalitäten nutzen zu können. + +Navigieren Sie danach zum Reiter 'Einstell.'. +Tragen Sie die nötige sog. 'Container ID' ein. Diese sieht in etwa so aus: 'GTM-W34LLOP'. + +Aktivieren Sie GA4 selbst, indem Sie dieses direkt darunter anhaken. + +--- + +Sie nutzen einen eigenen, als Modul im Shop installierten, Cookie-manager? Dann tragen Sie in den Folgeeinstellungen +unter "Cookie Manager Einstellungen", die Cookie-ID des zugehörigen Cookies ein. Und aktivieren Sie diese Weiche, +indem Sie den Haken bei "Eigenen Cookie Manager nutzen?" setzen. ## Changelog @@ -44,7 +68,7 @@ Siehe [CHANGELOG](CHANGELOG.md) für weitere Informationen. ## Beitragen -Wenn Sie eine Verbesserungsvorschlag haben, legen Sie einen Fork des Repositories an und erstellen Sie einen Pull Request. Alternativ können Sie einfach ein Issue erstellen. Fügen Sie das Projekt zu Ihren Favoriten hinzu. Vielen Dank. +Wenn Sie einen Verbesserungsvorschlag haben, legen Sie einen Fork des Repositories an und erstellen Sie einen Pull Request. Alternativ können Sie einfach ein Issue erstellen. Fügen Sie das Projekt zu Ihren Favoriten hinzu. Vielen Dank. - Erstellen Sie einen Fork des Projekts - Erstellen Sie einen Feature Branch (git checkout -b feature/AmazingFeature) diff --git a/metadata.php b/metadata.php index 5a001fd..6bf0213 100755 --- a/metadata.php +++ b/metadata.php @@ -8,7 +8,13 @@ $sMetadataVersion = '2.1'; $aModule = [ 'id' => 'd3googleanalytics4', 'title' => 'Google Analytics 4', - 'description' => 'Integration erfolgt via GoogleTagmanager und gtags.', + 'description' => "Dieses Modul bietet die Möglichkeit in Ihrem OXID eShop (6.x) die neue 'Property' + Google Analytics 4 (GA4) von Google zu integrieren.
+ Hierfür stehen Ihnen verschiedene 'templates' zur verfügung, + mit denen Sie bestimmte Events tracken können.
+ Beispiele dafür sind: view_item, add_to_basket, purchase, ...
+ Die Integration und Verbindung zu Google wird mti Hilfe des gtag (Google Tag Manager) erstellt. + ", 'thumbnail' => 'thumbnail.png', 'version' => '1.0.0.0', 'author' => 'Data Development (Inh.: Thomas Dartsch)', From b12884f99b35d83390404888e16c2d02629a524f Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Fri, 20 Jan 2023 09:38:25 +0100 Subject: [PATCH 25/29] fix namespace bug in composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ea310ba..846ea13 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ }, "autoload": { "psr-4": { - "D3\\GoogleAnalytics4": "../../../source/modules/d3/googleanalytics" + "D3\\GoogleAnalytics4\\": "../../../source/modules/d3/googleanalytics" } } } \ No newline at end of file From 69073c010940ca9399286bb911258d5fbccadee9 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Fri, 20 Jan 2023 09:57:38 +0100 Subject: [PATCH 26/29] adjusted desc text in metadata and paths to template files --- metadata.php | 52 +++++++++++++++++++--------------------------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/metadata.php b/metadata.php index 6bf0213..7b95f01 100755 --- a/metadata.php +++ b/metadata.php @@ -13,7 +13,8 @@ $aModule = [ Hierfür stehen Ihnen verschiedene 'templates' zur verfügung, mit denen Sie bestimmte Events tracken können.
Beispiele dafür sind: view_item, add_to_basket, purchase, ...
- Die Integration und Verbindung zu Google wird mti Hilfe des gtag (Google Tag Manager) erstellt. + Die Integration und Verbindung zu Google wird mti Hilfe des gtag (Google Tag Manager) erstellt.
+ Ursprüngliche Entwicklung: Marat Bedoev - Github-Link ", 'thumbnail' => 'thumbnail.png', 'version' => '1.0.0.0', @@ -25,23 +26,23 @@ $aModule = [ ], 'templates' => [ // GA4 events - 'ga4_add_payment_info.tpl' => 'vt/GoogleTagManager/Application/views/ga4/add_payment_info.tpl', - 'add_shipping_info.tpl' => 'vt/GoogleTagManager/Application/views/ga4/add_shipping_info.tpl', - 'ga4_add_to_cart.tpl' => 'vt/GoogleTagManager/Application/views/ga4/add_to_cart.tpl', - 'ga4_begin_checkout.tpl' => 'vt/GoogleTagManager/Application/views/ga4/begin_checkout.tpl', - 'ga4_generate_lead.tpl' => 'vt/GoogleTagManager/Application/views/ga4/generate_lead.tpl', - 'ga4_login.tpl' => 'vt/GoogleTagManager/Application/views/ga4/login.tpl', - 'ga4_purchase.tpl' => 'vt/GoogleTagManager/Application/views/ga4/purchase.tpl', - 'ga4_remove_from_cart.tpl' => 'vt/GoogleTagManager/Application/views/ga4/remove_from_cart.tpl', - 'ga4_search.tpl' => 'vt/GoogleTagManager/Application/views/ga4/search.tpl', - 'ga4_select_content.tpl' => 'vt/GoogleTagManager/Application/views/ga4/select_content.tpl', - 'ga4_select_item.tpl' => 'vt/GoogleTagManager/Application/views/ga4/select_item.tpl', - 'ga4_select_promotion.tpl' => 'vt/GoogleTagManager/Application/views/ga4/select_promotion.tpl', - 'ga4_sign_up.tpl' => 'vt/GoogleTagManager/Application/views/ga4/sign_up.tpl', - 'ga4_view_cart.tpl' => 'vt/GoogleTagManager/Application/views/ga4/view_cart.tpl', - 'ga4_view_item.tpl' => 'vt/GoogleTagManager/Application/views/ga4/view_item.tpl', - 'ga4_view_item_list.tpl' => 'vt/GoogleTagManager/Application/views/ga4/view_item_list.tpl', - 'ga4_view_promotion.tpl' => 'vt/GoogleTagManager/Application/views/ga4/view_promotion.tpl', + 'ga4_add_payment_info.tpl' => 'd3/googleanalytics4/Application/views/ga4/add_payment_info.tpl', + 'add_shipping_info.tpl' => 'd3/googleanalytics4/Application/views/ga4/add_shipping_info.tpl', + 'ga4_add_to_cart.tpl' => 'd3/googleanalytics4/Application/views/ga4/add_to_cart.tpl', + 'ga4_begin_checkout.tpl' => 'd3/googleanalytics4/Application/views/ga4/begin_checkout.tpl', + 'ga4_generate_lead.tpl' => 'd3/googleanalytics4/Application/views/ga4/generate_lead.tpl', + 'ga4_login.tpl' => 'd3/googleanalytics4/Application/views/ga4/login.tpl', + 'ga4_purchase.tpl' => 'd3/googleanalytics4/Application/views/ga4/purchase.tpl', + 'ga4_remove_from_cart.tpl' => 'd3/googleanalytics4/Application/views/ga4/remove_from_cart.tpl', + 'ga4_search.tpl' => 'd3/googleanalytics4/Application/views/ga4/search.tpl', + 'ga4_select_content.tpl' => 'd3/googleanalytics4/Application/views/ga4/select_content.tpl', + 'ga4_select_item.tpl' => 'd3/googleanalytics4/Application/views/ga4/select_item.tpl', + 'ga4_select_promotion.tpl' => 'd3/googleanalytics4/Application/views/ga4/select_promotion.tpl', + 'ga4_sign_up.tpl' => 'd3/googleanalytics4/Application/views/ga4/sign_up.tpl', + 'ga4_view_cart.tpl' => 'd3/googleanalytics4/Application/views/ga4/view_cart.tpl', + 'ga4_view_item.tpl' => 'd3/googleanalytics4/Application/views/ga4/view_item.tpl', + 'ga4_view_item_list.tpl' => 'd3/googleanalytics4/Application/views/ga4/view_item_list.tpl', + 'ga4_view_promotion.tpl' => 'd3/googleanalytics4/Application/views/ga4/view_promotion.tpl', /* 'gtm_ua_impression' => 'vt/GoogleTagManager/Application/views/ua/impression.tpl' 'gtm_view_promotion.tpl' => 'vt/GoogleTagManager/Application/views/view_promotion.tpl', @@ -152,21 +153,6 @@ $aModule = [ 'value' => true, 'position' => 1 ], - [ - 'group' => 'vt_gtm_settings', - 'name' => 'vt_gtm_blUAenabled', - 'type' => 'bool', - 'value' => true, - 'position' => 2 - ], - /*[ - I have no idea what this is - 'group' => 'vt_gtm_settings', - 'name' => 'vt_gtm_sMpapisecret', - 'type' => 'str', - 'value' => '', - 'position' => 3 - ],*/ [ 'group' => 'vt_gtm_settings', 'name' => 'vt_gtm_aPromotionlistIDs', From f41b2edeed08ba8ef597604b57640ba60e155099 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Fri, 20 Jan 2023 09:58:21 +0100 Subject: [PATCH 27/29] adjust target-directory --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 846ea13..2b2be84 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ "*.xml", "*.neon" ], - "target-directory": "d3/googleanalytics" + "target-directory": "d3/googleanalytics4" } }, "require": { @@ -51,7 +51,7 @@ }, "autoload": { "psr-4": { - "D3\\GoogleAnalytics4\\": "../../../source/modules/d3/googleanalytics" + "D3\\GoogleAnalytics4\\": "../../../source/modules/d3/googleanalytics4" } } } \ No newline at end of file From d9b8c274cec10886fbc5a116be384d969a2893ad Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Fri, 20 Jan 2023 11:04:04 +0100 Subject: [PATCH 28/29] adjusted keywords and desc in composer.json --- composer.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 2b2be84..42c6045 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "d3/google-analytics4", - "description": "Google Tag Manager with new Google Analytics 4 for OXID eShop 6.x", + "description": "Google Tag Manager with new Google Analytics 4 for OXID eShop v6", "type": "oxideshop-module", "keywords": [ "oxid", @@ -11,8 +11,7 @@ "ga4", "googleanalytics", "gtm", - "configuration", - "license" + "configuration" ], "homepage": "https://www.d3data.de", "license": [ From f6f4f876279993282f463dcf65257efa0070e427 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Fri, 20 Jan 2023 11:04:22 +0100 Subject: [PATCH 29/29] adjusted general texts of the mod --- Application/views/admin/de/module_options.php | 10 ++++------ README.md | 6 ++++-- metadata.php | 15 +++++---------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/Application/views/admin/de/module_options.php b/Application/views/admin/de/module_options.php index 46ce86a..b99525b 100755 --- a/Application/views/admin/de/module_options.php +++ b/Application/views/admin/de/module_options.php @@ -17,7 +17,7 @@ $style = '