Project

General

Profile

GX-Bug #55362

Tracking Codes um weitere Positionen und Funktionalitäten erweitern | Extend tracking codes by additional positions and features

Added by Jan-Olof Kratzke almost 4 years ago. Updated about 2 years ago.

Status:
Erledigt
Priority:
Normal
Category:
Sonstiges
Target version:
% Done:

100%

Estimated time:
Steps to reproduce:
Betroffene Versionen:
Unbestimmt
Release Notes Langtext:

SEO→Tracking-Codes erweitert um Codes im Head und Bestellabschluss; Tracking-Codes können jetzt Smarty-Code enthalten


Description

Wir bekommen Rückmeldungen von Kundenseite dass Google Analytics Codes im Head eingebunden werden müssen, damit diese von Google erkannt werden. Standardmäßig werden Tracking-Codes jedoch am unteren Ende des Bodys angezeigt.
Die Einstellung unter Shop Einstellungen > SEO > Tracking-Codes sollte um eine Option erweitert werden, den Tracking-Code wahlweise in Head oder Body anzuzeigen.

History

#1

Updated by Marco Bruchmann about 2 years ago

  • Subject changed from Tracking Codes im Head einbindbar machen to Tracking Codes um weitere Positionen und Funktionalitäten erweitern | Extend tracking codes by additional positions and features
  • Assignee set to Marco Bruchmann

Die Tracking Codes sollten dahingehend erweitert werden, dass zusätzliche Einbindungen im Head-Bereich der Seite und auf der Bestellabschlussseite (checkout_success) möglich werden. Hierbei sollten die Tracking Codes auch durch Smarty geparst werden, um zusätzliche Funktionalität und Datenquellen zu erschließen.


Tracking Codes should be extended to include additional tracking codes in the head section of each page and on the final page of the checkout (checkout_success). The codes should also be parsed by Smarty to allow for additional functionality and data sources.


Examples:

Tracking Code (head):

<script>
document.addEventListener('DOMContentLoaded', function() {
document.querySelectorAll('div').forEach(function(d) { d.style.boxShadow = '0 0 10px red'; });
});
let cartData = {$smarty.session.cart|json_encode};
</script>
<!-- Test Smarty: {42 + 23} -->

Will add a red shadow around each div element, inject $_SESSION['cart'] as a JSON object (quite pointless; just for illustration) and output the sum of 42 and 23 in an HTML comment.
Note the use of native Javascript here: jQuery is not available at this point in the page!

Tracking Code (bottom):

<script>
$('p').css('background-color', 'cornsilk');
</script>
<p>
{'c'|date}
</p>
<pre>{$_GLOBALS.order|print_r}</pre>

Here, jQuery is available and used to set the background color of all p elements to cornsilk. Also, a date is output through a Smarty call.

Tracking Code (checkout_success):

<p>
{foreach $order->getOrderItems() as $oItem}
  {$oItem->getQuantity()} {$oItem->getName()} ({$oItem->getProductModel()}) für {$oItem->getPrice()|number_format:2} {$order->getCurrencyCode()->getCode()}<br>
{/foreach}
</p>
<p>Hello, there!</p>
<script>
document.write('hallo {$legacyOrder->info['payment_method']}');
if(true) { document.write('Moin.'); }
</script>

On the checkout_success page, additional Smarty variables $order and $legacyOrder are available. The $order is an implementation of OrderInterface, the result of a call to OrderReadService::getOrderById(). The $legacyOrder is simply an instance of includes/classes/order.inc.php.

Also, note that Smarty and Javascript code can be interspersed if the braces ({}) in Javascript code are followed by spaces.

#2

Updated by Marco Bruchmann about 2 years ago

  • Status changed from Gemeldet to Testing
  • Assignee changed from Marco Bruchmann to Core-Entwickler
  • Release Notes Langtext updated (diff)
#3

Updated by Ahmed Hamouda about 2 years ago

  • Target version changed from 58 to 3.15.3.1
#5

Updated by Marvin Muxfeld about 2 years ago

  • Assignee changed from Core-Entwickler to Marvin Muxfeld
#6

Updated by Ahmed Hamouda about 2 years ago

  • Status changed from Testing to Erledigt
  • % Done changed from 0 to 100
#7

Updated by Mirko Janssen about 2 years ago

  • Tracker changed from GX-Feature to GX-Bug

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 5 MB)