From 3d62993dfc1ee8eebd284ff5291d5b3a4f71bc55 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Thu, 1 Jun 2023 14:19:29 +0200 Subject: [PATCH 1/3] add missing consentmanager readme entry --- Docs/README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Docs/README.md b/Docs/README.md index 2a926dc..9221f81 100644 --- a/Docs/README.md +++ b/Docs/README.md @@ -65,4 +65,12 @@ Aktivieren Sie anschließend diese Weiche. Setzen Sie den Haken bei "Eigenen Coo - [OXID Cookie Management powered by usercentrics](https://docs.oxid-esales.com/modules/usercentrics/de/latest/einfuehrung.html) - In der Usercentrics-Verwaltung die Services "Google Analytics" und "Google Tag Manager" anlegen - Den Service ```Google Tag Manager``` in den Moduleinstellungen des 'Google Analytics 4' unter - ```Einstell. > Cookie Manager Einstellungen > Cookie-ID``` eintragen \ No newline at end of file + Google Tag Manager eintragen + - +- [Consent Management Provider](https://www.consentmanager.net/) + - In der Consentmanager-Oberfläche den Anbieter "Google Tag Manager" mit der ID s905 hinzufügen + - Im Frontend, im consentmanager-Pop-up nach dem 'Google Tag Manager' suchen + - kleines Fragezeichen neben den Namen anklicken und ganz runter scrollen + - prüfen, ob ein Cookie vorgegeben ist + - sonst, in der Consentmanager-Oberfläche Cookie-Liste entsprechendes Cookie suchen und im Admin unter + ```Einstell. > Cookie Manager Einstellungen > Cookie-ID``` eintragen \ No newline at end of file From b4bf91660e3ed02db2d88b2fa1f9576b3359ba51 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Mon, 19 Jun 2023 11:34:45 +0200 Subject: [PATCH 2/3] [rework] change structure of GA-event moving the procedere into one step so there's not an accidental triggering of an GA-Push-Event which at the end overwrites the View-Item-Push-Event in the cmpEvent --- Application/views/ga4/add_to_cart.tpl | 81 ++++++++++++--------------- 1 file changed, 36 insertions(+), 45 deletions(-) diff --git a/Application/views/ga4/add_to_cart.tpl b/Application/views/ga4/add_to_cart.tpl index 0721a48..700d44b 100644 --- a/Application/views/ga4/add_to_cart.tpl +++ b/Application/views/ga4/add_to_cart.tpl @@ -1,56 +1,47 @@ [{$smarty.block.parent}] -[{assign var="d3ProductObject" value=$oView->getProduct()}] -[{assign var="d3PriceObject" value=$d3ProductObject->getPrice()}] +[{* variable $gtmProduct is passed from parent tempalte *}] +[{assign var="d3PriceObject" value=$gtmProduct->getPrice()}] +[{assign var="gtmCurrency" value=$oView->getActCurrency()}] +[{assign var="gtmManufacturer" value=$gtmProduct->getManufacturer()}] +[{assign var="gtmCategory" value=$gtmProduct->getCategory()}] [{capture assign=d3_ga4_add_to_cart}] -[{block name="d3_ga4_add_to_basket"}] + [{block name="d3_ga4_add_to_basket"}] $("#toBasket").click(function(event) { + dataLayer.push({"event": null, "eventLabel": null, "ecommerce": null}); /* Clear the previous ecommerce object. */ - [{*** Debug cases ***}] - [{*event.preventDefault();*}] + let itemCategories = '[{if $gtmCategory}][{$gtmCategory->getLink()|parse_url:5|ltrim:"/"|rtrim:"/"}][{else}]no category[{/if}]'.split('/'); - let iArtQuantity = $("#amountToBasket").val(); + [{*** Debug cases ***}] + [{*event.preventDefault();*}] - dataLayer.push({ - 'isAddToBasket': true, - 'event':'add_to_cart', - 'eventLabel': 'add_to_cart', - 'ecommerce': { - 'currency': "[{$currency->name}]", - 'value': iArtQuantity*[{$d3PriceObject->getPrice()}], - 'items': [ - { - 'item_id': '[{$gtmProduct->getFieldData('oxartnum')}]', - 'item_name': '[{$gtmProduct->getFieldData('oxtitle')}]', - 'price': [{$d3PriceObject->getPrice()}], - 'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]', - 'item_variant': '[{if $gtmProduct->getFieldData('oxvarselect')}][{$gtmProduct->getFieldData('oxvarselect')}][{/if}]', - 'item_category': itemCategories[0] || 'no category', - 'item_category_2':itemCategories[1] || '', - 'item_category_3':itemCategories[2] || '', - 'item_category_4':itemCategories[3] || '', - 'quantity': iArtQuantity - } - ] + let iArtQuantity = $("#amountToBasket").val(); + + dataLayer.push({ + 'isAddToBasket': true, + 'event':'add_to_cart', + 'eventLabel': 'add_to_cart', + 'ecommerce': { + 'currency': "[{$currency->name}]", + 'value': iArtQuantity*[{$d3PriceObject->getPrice()}], + 'items': [ + { + 'item_id': '[{$gtmProduct->getFieldData('oxartnum')}]', + 'item_name': '[{$gtmProduct->getFieldData('oxtitle')}]', + 'price': [{$d3PriceObject->getPrice()}], + 'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]', + 'item_variant': '[{if $gtmProduct->getFieldData('oxvarselect')}][{$gtmProduct->getFieldData('oxvarselect')}][{/if}]', + 'item_category': itemCategories[0] || 'no category', + 'item_category_2':itemCategories[1] || '', + 'item_category_3':itemCategories[2] || '', + 'item_category_4':itemCategories[3] || '', + 'quantity': iArtQuantity + } + ] } }); }); -[{/block}] -[{/capture}] -[{oxscript add=$d3_ga4_add_to_cart}] - -[{strip}] - [{* 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 + [{/block}] + [{/capture}] +[{oxscript add=$d3_ga4_add_to_cart}] \ No newline at end of file From e48b21022cd2bae2e94b5cb8e2ba4889b8e570c5 Mon Sep 17 00:00:00 2001 From: MaxBUhe Date: Mon, 19 Jun 2023 15:17:43 +0200 Subject: [PATCH 3/3] bump version && changelog to 2.7.0 --- CHANGELOG.md | 4 ++++ metadata.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d7d9f8..6e6c0fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.7.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.6.0...2.7.0) - 2023-06-19 +### Changed +- add_to_cart event template-structure + ## [2.6.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.5.0...2.6.0) - 2023-05-31 ### Added - add settings to explicit choose an external service (usercentrics/ consentmanager) diff --git a/metadata.php b/metadata.php index a4d8b37..5a0b4f7 100755 --- a/metadata.php +++ b/metadata.php @@ -17,7 +17,7 @@ $aModule = [ Die Entwicklung basiert auf einem Fork von Marat Bedoev - Github-Link ", 'thumbnail' => 'thumbnail.png', - 'version' => '2.6.0', + 'version' => '2.7.0', 'author' => 'Data Development (Inh.: Thomas Dartsch)', 'email' => 'support@shopmodule.com', 'url' => 'https://www.oxidmodule.com/',