- Change item_category_X to item_categoryX etc.
- add item_brand to all events - add option to use real category titles instead of url parts for item_categoryX - add option to replace chars in item_categoryX values thanks to Stefan Moisees@beffy@proudcommerce.com
This commit is contained in:
@ -37,6 +37,7 @@ class GA4AdminUserInterface_main extends \OxidEsales\Eshop\Application\Controlle
|
||||
'_blEnableDebug',
|
||||
'_blEnableConsentMode',
|
||||
'_blEnableOwnCookieManager',
|
||||
'_blUseRealCategoyTitles',
|
||||
'_blEnableMeasurementCapabilities',
|
||||
'_blEnableUsercentricsConsentModeApi',
|
||||
];
|
||||
|
@ -39,6 +39,11 @@ return [
|
||||
<br>
|
||||
Ein einfaches anschalten dieser Funktion regelt noch <strong>nicht</strong> die völlige Funktionsweise
|
||||
aller beteiligten Instanzen; diese bedarf eine detailliertere Konfiguration!<br>",
|
||||
'D3USEREALCATTITLES' => "Für 'item_category'-Werte die Kategorie-Titel verwenden?",
|
||||
'D3USEREALCATTITLES_HELP' => "Für die 'item_category' Werte keine URL-Teile, sondern die Klartext-Kategorie-Titel verwenden, also z.B. 'Haarbürsten' statt 'haarbuersten'.",
|
||||
|
||||
'D3REPLACECHARS' => "Zeichen ersetzen",
|
||||
'D3REPLACECHARS_HELP' => 'Hier alle Zeichen, die aus Kategorie-Titeln entfernt werden sollen, eintragen, also z.B. " um ein Zoll-Zeichen zu entfernen oder "0-9 um das Zollzeichen und alle Ziffern zu entfernen.',
|
||||
|
||||
// Use CMP?
|
||||
'D3CMPTABTITLE' => 'Cookie Manager Einstellungen',
|
||||
|
@ -2,16 +2,56 @@
|
||||
|
||||
namespace D3\GoogleAnalytics4\Modules\Application\Model;
|
||||
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
use OxidEsales\Eshop\Core\ViewConfig;
|
||||
|
||||
trait articleTreeStructure
|
||||
{
|
||||
/**
|
||||
* Get all parent category titles, starting from the base category.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getParentCategoryTitles() :array
|
||||
{
|
||||
$parentTitles[] = $this->getTitle();
|
||||
// we may be in Manufacturer, Vendor, etc.
|
||||
if (method_exists($this, 'getParentCategory')) {
|
||||
$parent = $this->getParentCategory();
|
||||
while ($parent != null) {
|
||||
$parentTitles[] = $parent->getTitle();
|
||||
$parent = $parent->getParentCategory();
|
||||
}
|
||||
}
|
||||
return array_reverse(array_map([$this, 'cleanUpTitle'], $parentTitles));
|
||||
}
|
||||
/**
|
||||
* Cleanup title, decode entities, remove some chars and trim
|
||||
*
|
||||
* @param string $title
|
||||
* @return string
|
||||
*/
|
||||
public function cleanUpTitle($title) :string
|
||||
{
|
||||
// decode encoded characters
|
||||
$title = html_entity_decode($title, ENT_QUOTES);
|
||||
// remove unwanted characters, e.g. Zoll "
|
||||
$charsToReplace = Registry::get(ViewConfig::class)->getCharsToReplaceInCategorTitles();
|
||||
$title = preg_replace('/[' . $charsToReplace . ']/', '', $title);
|
||||
// trim whitespace from both ends of the string
|
||||
$title = trim($title);
|
||||
return $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $indexOfArray
|
||||
* @return string
|
||||
*/
|
||||
public function getSplitCategoryArray(int $indexOfArray = -1, bool $bShallTakeStd = false): string
|
||||
{
|
||||
if ($bShallTakeStd) {
|
||||
$splitCatArray =
|
||||
if ($bShallTakeStd){
|
||||
$bUseRealCatTitles = (bool)Registry::get(ViewConfig::class)->d3GetModuleConfigParam('_blUseRealCategoyTitles');
|
||||
$splitCatArray = $bUseRealCatTitles ? $this->getParentCategoryTitles() :
|
||||
array_values(
|
||||
array_filter(
|
||||
explode(
|
||||
|
@ -66,6 +66,14 @@ class ViewConfig extends ViewConfig_parent
|
||||
return (bool) $this->d3GetModuleConfigParam('_blEnableOwnCookieManager');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCharsToReplaceInCategorTitles(): string
|
||||
{
|
||||
return (string) $this->d3GetModuleConfigParam('_sReplaceChars');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
@ -208,9 +216,20 @@ class ViewConfig extends ViewConfig_parent
|
||||
return json_encode([$dataLayer], JSON_PRETTY_PRINT);
|
||||
}
|
||||
|
||||
public function isDebugModeOn(): bool
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isDebugModeOn() :bool
|
||||
{
|
||||
return $this->d3GetModuleConfigParam("_blEnableDebug") ?: false;
|
||||
return $this->d3GetModuleConfigParam("_blEnableDebug")?: false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function useRealCategoryTitles(): bool
|
||||
{
|
||||
return $this->d3GetModuleConfigParam("_blUseRealCategoyTitles") ?: false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,6 +54,24 @@
|
||||
[{oxmultilang ident="D3USEGOOGLECONSENTMODE"}][{oxinputhelp ident="D3USEGOOGLECONSENTMODE_HELP"}]
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" value="" id="_blUseRealCategoyTitles"
|
||||
name="editval[bool][_blUseRealCategoyTitles]"
|
||||
[{if $d3ViewObject->d3GetModuleConfigParam('_blUseRealCategoyTitles')}]checked[{/if}]>
|
||||
<label class="form-check-label" for="flexCheckChecked">
|
||||
[{oxmultilang ident="D3USEREALCATTITLES"}][{oxinputhelp ident="D3USEREALCATTITLES_HELP"}]
|
||||
</label>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<div class="input-group w-50">
|
||||
<span class="input-group-text"
|
||||
id="basic-addon3">[{oxmultilang ident="D3REPLACECHARS"}]</span>
|
||||
<input type="text" class="form-control" id="_sReplaceChars"
|
||||
name="editval[str][_sReplaceChars]" aria-describedby="basic-addon3"
|
||||
value='[{$d3ViewObject->d3GetModuleConfigParam('_sReplaceChars')}]'/>
|
||||
</div>
|
||||
<div class="text-muted">[{oxmultilang ident="D3REPLACECHARS_HELP"}]</div>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" name="save" class="btn btn-light" onClick="Javascript:document.d3gtmformedit.fnc.value='save'">[{oxmultilang ident="GENERAL_SAVE"}]</button>
|
||||
</div>
|
||||
|
@ -28,13 +28,14 @@
|
||||
{
|
||||
'item_oxid': '[{$gtmCartArticles[$basketindex]->getFieldData('oxid')}]',
|
||||
'item_id': '[{$gtmCartArticles[$basketindex]->getFieldData('oxartnum')}]',
|
||||
'item_name': '[{$gtmCartArticles[$basketindex]->getFieldData('oxtitle')}]',
|
||||
'item_name': '[{$gtmCartArticles[$basketindex]->getRawFieldData('oxtitle')}]',
|
||||
'item_variant': '[{$gtmCartArticles[$basketindex]->getFieldData('oxvarselect')}]',
|
||||
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
|
||||
[{if $gtmBasketItemCategory}]
|
||||
'item_category': '[{$gtmBasketItemCategory->getSplitCategoryArray(0, true)}]',
|
||||
'item_category_2': '[{$gtmBasketItemCategory->getSplitCategoryArray(1, true)}]',
|
||||
'item_category_3': '[{$gtmBasketItemCategory->getSplitCategoryArray(2, true)}]',
|
||||
'item_category_4': '[{$gtmBasketItemCategory->getSplitCategoryArray(3, true)}]',
|
||||
'item_category2': '[{$gtmBasketItemCategory->getSplitCategoryArray(1, true)}]',
|
||||
'item_category3': '[{$gtmBasketItemCategory->getSplitCategoryArray(2, true)}]',
|
||||
'item_category4': '[{$gtmBasketItemCategory->getSplitCategoryArray(3, true)}]',
|
||||
'item_list_name': '[{$gtmBasketItemCategory->getSplitCategoryArray()}]',
|
||||
[{/if}]
|
||||
'price': [{$gtmItemPriceObject->getPrice()}],
|
||||
|
@ -37,16 +37,16 @@
|
||||
{
|
||||
'item_oxid': '[{$oGtmProduct->getFieldData('oxid')}]',
|
||||
'item_id': '[{$oGtmProduct->getFieldData('oxartnum')}]',
|
||||
'item_name': '[{$oGtmProduct->getFieldData('oxtitle')}]',
|
||||
'price': [{$d3PriceObject->getPrice()}],
|
||||
'item_name': '[{$oGtmProduct->getRawFieldData('oxtitle')}]',
|
||||
[{oxhasrights ident="SHOWARTICLEPRICE"}]'price': [{$d3PriceObject->getPrice()}],[{/oxhasrights}]
|
||||
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
|
||||
'item_variant': '[{if $oGtmProduct->getFieldData('oxvarselect')}][{$oGtmProduct->getFieldData('oxvarselect')}][{/if}]',
|
||||
[{if $gtmCategory}]
|
||||
'item_category': '[{$gtmCategory->getSplitCategoryArray(0, true)}]',
|
||||
'item_category_2':'[{$gtmCategory->getSplitCategoryArray(1, true)}]',
|
||||
'item_category_3':'[{$gtmCategory->getSplitCategoryArray(2, true)}]',
|
||||
'item_category_4':'[{$gtmCategory->getSplitCategoryArray(3, true)}]',
|
||||
'item_list_name':'[{$gtmCategory->getSplitCategoryArray()}]',
|
||||
'item_category2': '[{$gtmCategory->getSplitCategoryArray(1, true)}]',
|
||||
'item_category3': '[{$gtmCategory->getSplitCategoryArray(2, true)}]',
|
||||
'item_category4': '[{$gtmCategory->getSplitCategoryArray(3, true)}]',
|
||||
'item_list_name': '[{$gtmCategory->getSplitCategoryArray()}]',
|
||||
[{/if}]
|
||||
'quantity': iArtQuantity
|
||||
}
|
||||
|
@ -24,16 +24,18 @@
|
||||
[{assign var="d3oItemPrice" value=$basketitem->getPrice()}]
|
||||
[{assign var="gtmBasketItem" value=$basketitem->getArticle()}]
|
||||
[{assign var="gtmBasketItemCategory" value=$gtmBasketItem->getCategory()}]
|
||||
[{assign var="gtmManufacturer" value=$gtmBasketItem->getManufacturer()}]
|
||||
{
|
||||
'item_oxid': '[{$gtmCartArticles[$basketindex]->getFieldData('oxid')}]',
|
||||
'item_id': '[{$gtmCartArticles[$basketindex]->getFieldData('oxartnum')}]',
|
||||
'item_name': '[{$gtmCartArticles[$basketindex]->getFieldData('oxtitle')}]',
|
||||
'item_name': '[{$gtmCartArticles[$basketindex]->getRawFieldData('oxtitle')}]',
|
||||
'item_variant': '[{$gtmCartArticles[$basketindex]->getFieldData('oxvarselect')}]',
|
||||
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
|
||||
[{if $gtmBasketItemCategory}]
|
||||
'item_category': '[{$gtmBasketItemCategory->getSplitCategoryArray(0, true)}]',
|
||||
'item_category_2': '[{$gtmBasketItemCategory->getSplitCategoryArray(1, true)}]',
|
||||
'item_category_3': '[{$gtmBasketItemCategory->getSplitCategoryArray(2, true)}]',
|
||||
'item_category_4': '[{$gtmBasketItemCategory->getSplitCategoryArray(3, true)}]',
|
||||
'item_category2': '[{$gtmBasketItemCategory->getSplitCategoryArray(1, true)}]',
|
||||
'item_category3': '[{$gtmBasketItemCategory->getSplitCategoryArray(2, true)}]',
|
||||
'item_category4': '[{$gtmBasketItemCategory->getSplitCategoryArray(3, true)}]',
|
||||
'item_list_name': '[{$gtmBasketItemCategory->getSplitCategoryArray()}]',
|
||||
[{/if}]
|
||||
'price': [{$d3oItemPrice->getPrice()}],
|
||||
|
@ -26,19 +26,21 @@
|
||||
[{assign var="gtmPurchaseItemPriceObject" value=$gtmBasketItem->getPrice()}]
|
||||
[{assign var="gtmPurchaseItem" value=$gtmBasketItem->getArticle()}]
|
||||
[{assign var="gtmPurchaseItemCategory" value=$gtmPurchaseItem->getCategory()}]
|
||||
[{assign var="gtmManufacturer" value=$gtmPurchaseItem->getManufacturer()}]
|
||||
|
||||
{
|
||||
'item_oxid': '[{$gtmBasketItem->getFieldData("oxid")}]',
|
||||
'item_id': '[{$gtmBasketItem->getFieldData("oxartnum")}]',
|
||||
'item_name': '[{$gtmBasketItem->getFieldData("oxtitle")}]',
|
||||
'affiliation': '[{$gtmBasketItem->getFieldData("oxtitle")}]',
|
||||
'item_name': '[{$gtmBasketItem->getRawFieldData("oxtitle")}]',
|
||||
'affiliation': '[{$gtmBasketItem->getRawFieldData("oxtitle")}]',
|
||||
'coupon': '[{foreach from=$gtmOrderVouchers item="gtmOrderVoucher" name="gtmOrderVoucherIteration"}][{$gtmOrderVoucher}][{if !$smarty.foreach.gtmOrderVoucherIteration.last}], [{/if}][{/foreach}]',
|
||||
'item_variant': '[{$gtmBasketItem->getFieldData("oxselvariant")}]',
|
||||
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
|
||||
[{if $gtmPurchaseItemCategory}]
|
||||
'item_category': '[{$gtmPurchaseItemCategory->getSplitCategoryArray(0, true)}]',
|
||||
'item_category_2': '[{$gtmPurchaseItemCategory->getSplitCategoryArray(1, true)}]',
|
||||
'item_category_3': '[{$gtmPurchaseItemCategory->getSplitCategoryArray(2, true)}]',
|
||||
'item_category_4': '[{$gtmPurchaseItemCategory->getSplitCategoryArray(3, true)}]',
|
||||
'item_category2': '[{$gtmPurchaseItemCategory->getSplitCategoryArray(1, true)}]',
|
||||
'item_category3': '[{$gtmPurchaseItemCategory->getSplitCategoryArray(2, true)}]',
|
||||
'item_category4': '[{$gtmPurchaseItemCategory->getSplitCategoryArray(3, true)}]',
|
||||
'item_list_name': '[{$gtmPurchaseItemCategory->getSplitCategoryArray()}]',
|
||||
[{/if}]
|
||||
'price': [{$gtmPurchaseItemPriceObject->getPrice()}],
|
||||
|
@ -20,13 +20,13 @@
|
||||
{
|
||||
'item_oxid': '[{$rmItem->getFieldData('oxid')}]',
|
||||
'item_id': '[{$rmItem->getFieldData('oxartnum')}]',
|
||||
'item_name': '[{$rmItem->getFieldData('oxtitle')}]',
|
||||
'item_name': '[{$rmItem->getRawFieldData('oxtitle')}]',
|
||||
'item_variant': '[{$rmItem->getFieldData('oxvarselect')}]',
|
||||
[{if $gtmBasketItemCategory}]
|
||||
'item_category': '[{$gtmBasketItemCategory->getSplitCategoryArray(0, true)}]',
|
||||
'item_category_2': '[{$gtmBasketItemCategory->getSplitCategoryArray(1, true)}]',
|
||||
'item_category_3': '[{$gtmBasketItemCategory->getSplitCategoryArray(2, true)}]',
|
||||
'item_category_4': '[{$gtmBasketItemCategory->getSplitCategoryArray(3, true)}]',
|
||||
'item_category2': '[{$gtmBasketItemCategory->getSplitCategoryArray(1, true)}]',
|
||||
'item_category3': '[{$gtmBasketItemCategory->getSplitCategoryArray(2, true)}]',
|
||||
'item_category4': '[{$gtmBasketItemCategory->getSplitCategoryArray(3, true)}]',
|
||||
'item_list_name': '[{$gtmBasketItemCategory->getSplitCategoryArray()}]',
|
||||
[{/if}]
|
||||
'price': [{$d3oItemPrice->getPrice()}],
|
||||
|
@ -25,13 +25,13 @@
|
||||
{
|
||||
'item_oxid': '[{$gtmCartArticles[$basketindex]->getFieldData('oxid')}]',
|
||||
'item_id': '[{$gtmCartArticles[$basketindex]->getFieldData('oxartnum')}]',
|
||||
'item_name': '[{$gtmCartArticles[$basketindex]->getFieldData('oxtitle')}]',
|
||||
'item_name': '[{$gtmCartArticles[$basketindex]->getRawFieldData('oxtitle')}]',
|
||||
'item_variant': '[{$gtmCartArticles[$basketindex]->getFieldData('oxvarselect')}]',
|
||||
[{if $gtmBasketItemCategory}]
|
||||
'item_category': '[{$gtmBasketItemCategory->getSplitCategoryArray(0, true)}]',
|
||||
'item_category_2': '[{$gtmBasketItemCategory->getSplitCategoryArray(1, true)}]',
|
||||
'item_category_3': '[{$gtmBasketItemCategory->getSplitCategoryArray(2, true)}]',
|
||||
'item_category_4': '[{$gtmBasketItemCategory->getSplitCategoryArray(3, true)}]',
|
||||
'item_category2': '[{$gtmBasketItemCategory->getSplitCategoryArray(1, true)}]',
|
||||
'item_category3': '[{$gtmBasketItemCategory->getSplitCategoryArray(2, true)}]',
|
||||
'item_category4': '[{$gtmBasketItemCategory->getSplitCategoryArray(3, true)}]',
|
||||
'item_list_name': '[{$gtmBasketItemCategory->getSplitCategoryArray()}]',
|
||||
[{/if}]
|
||||
'price': [{$d3oItemPrice->getPrice()}],
|
||||
|
@ -22,11 +22,11 @@
|
||||
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
|
||||
'item_variant': '[{if $gtmProduct->getFieldData("oxvarselect")}][{$gtmProduct->getFieldData("oxvarselect")}][{/if}]',
|
||||
[{if $gtmCategory}]
|
||||
'item_category': '[{$gtmCategory->getSplitCategoryArray(0, true)}]',
|
||||
'item_category_2':'[{$gtmCategory->getSplitCategoryArray(1, true)}]',
|
||||
'item_category_3':'[{$gtmCategory->getSplitCategoryArray(2, true)}]',
|
||||
'item_category_4':'[{$gtmCategory->getSplitCategoryArray(3, true)}]',
|
||||
'item_list_name':'[{$gtmCategory->getSplitCategoryArray()}]',
|
||||
'item_category': '[{$gtmCategory->getSplitCategoryArray(0, true)}]',
|
||||
'item_category2': '[{$gtmCategory->getSplitCategoryArray(1, true)}]',
|
||||
'item_category3': '[{$gtmCategory->getSplitCategoryArray(2, true)}]',
|
||||
'item_category4': '[{$gtmCategory->getSplitCategoryArray(3, true)}]',
|
||||
'item_list_name': '[{$gtmCategory->getSplitCategoryArray()}]',
|
||||
[{/if}]
|
||||
[{assign var="d3PriceObject" value=$gtmProduct->getPrice()}]
|
||||
'price': [{$d3PriceObject->getPrice()}]
|
||||
|
@ -22,14 +22,14 @@
|
||||
{
|
||||
'item_oxid': '[{$gtmProduct->getFieldData("oxid")}]',
|
||||
'item_id': '[{$gtmProduct->getFieldData("oxartnum")}]',
|
||||
'item_name': '[{$gtmProduct->getFieldData("oxtitle")}]',
|
||||
'price': [{$d3PriceObject->getPrice()}],
|
||||
'item_name': '[{$gtmProduct->getRawFieldData("oxtitle")}]',
|
||||
[{oxhasrights ident="SHOWARTICLEPRICE"}]'price': [{$d3PriceObject->getPrice()}],[{/oxhasrights}]
|
||||
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
|
||||
[{if $gtmCategory}]
|
||||
'item_category': '[{$gtmCategory->getSplitCategoryArray(0, true)}]',
|
||||
'item_category_2':'[{$gtmCategory->getSplitCategoryArray(1, true)}]',
|
||||
'item_category_3':'[{$gtmCategory->getSplitCategoryArray(2, true)}]',
|
||||
'item_category_4':'[{$gtmCategory->getSplitCategoryArray(3, true)}]',
|
||||
'item_category': '[{$gtmCategory->getSplitCategoryArray(0, true)}]',
|
||||
'item_category2': '[{$gtmCategory->getSplitCategoryArray(1, true)}]',
|
||||
'item_category3': '[{$gtmCategory->getSplitCategoryArray(2, true)}]',
|
||||
'item_category4': '[{$gtmCategory->getSplitCategoryArray(3, true)}]',
|
||||
[{/if}]
|
||||
'quantity': 1
|
||||
}[{if !$smarty.foreach.gtmProducts.last}],[{/if}]
|
||||
|
@ -23,9 +23,9 @@
|
||||
'item_brand': '[{if $gtmManufacturer}][{$gtmManufacturer->oxmanufacturers__oxtitle->value}][{/if}]',
|
||||
[{if $gtmCategory}]
|
||||
'item_category': '[{$gtmCategory->getSplitCategoryArray(0, true)}]',
|
||||
'item_category_2':'[{$gtmCategory->getSplitCategoryArray(1, true)}]',
|
||||
'item_category_3':'[{$gtmCategory->getSplitCategoryArray(2, true)}]',
|
||||
'item_category_4':'[{$gtmCategory->getSplitCategoryArray(3, true)}]',
|
||||
'item_category2': '[{$gtmCategory->getSplitCategoryArray(1, true)}]',
|
||||
'item_category3': '[{$gtmCategory->getSplitCategoryArray(2, true)}]',
|
||||
'item_category4': '[{$gtmCategory->getSplitCategoryArray(3, true)}]',
|
||||
'item_list_name':'[{$gtmCategory->getSplitCategoryArray()}]',
|
||||
[{/if}]
|
||||
'quantity': 1
|
||||
|
Reference in New Issue
Block a user