Google Tag Manager
Variablen
Konstanten
{{Makaira Tracking ID}} | wird vom Makaira Support bereitgestellt |
Data Layer Variablen (DLV)
{{DLV - addedToCart}} | Object: Zum Warenkorb hinzugefügtes Produkt mit Feldern `sku`,`name`, `price` (Einzelpreis), `category` (Kategorie-Titel) und `quantity` |
{{DLV - totalCartValue}} | Float: Gesamter Warenkorbwert in der aktuellen Währung |
{{DLV - order}} | Object: Eine Bestellung mit den Feldern id, revenue, subtotal, tax, shippingtotal, discounttotal und products (gekaufte Produkte - jeweils `name`, `price` (Einzelpreis), `category` (Kategorie-Titel) und `quantity` sowie `sku`) |
{{DLV - pageType}} | String: Typ der Seite - entweder `product` (Produktdetailseite) oder `category` (Kategorieseite) oder `searchresults` (Suchergebnisseite) |
{{DLV - pageType}} | String: Typ der Seite - entweder `product` (Produktdetailseite) oder `category` (Kategorieseite) oder `searchresults` (Suchergebnisseite) |
{{DLV - category}} | String: Kategorie-Name der aktuellen Kategorie (auf Kategorieseite) |
{{DLV - search}} | Object: Suche `searchTerm` (Suchbegriff) `resultCount` (Anzahl der Suchergebnisse) |
Tags
Name: Makaira Tracking - Base Tag
Typ: Custom HTML
Trigger: All Pages
<script type="text/javascript">
var _paq = window._paq || [];
_paq.push(['enableLinkTracking']);
(function() {
var u="https://piwik.makaira.io/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', {{Makaira Tracking ID}}]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
Name: Makaira Tracking - AddToCart
Typ: Custom HTML
Trigger: addToCart - Custom Event
<script type="text/javascript">
(function() {
console.log('3PT - Piwik - AddToCart Tag');
if (typeof window._paq === 'object') {
var product = {{DLV - addedToCart}}
_paq.push(["addEcommerceItem",product.sku,product.name,product.category,product.price,product.quantitiy])
_paq.push(["trackEcommerceCartUpdate",{{DLV - totalCartValue}}]);
}
})();
</script>
Tag: Makaira Tracking - Purchase
Typ: Custom HTML
Trigger: Pages mit thank-you-URL oder Custom Event - Purchase
<script type="text/javascript">
(function() {
if (typeof window._paq === 'object') {
var order = {{DLV - order}};
var order_items = order.products;
for(var i = 0; i < order_items.length; i++){
_paq.push(["addEcommerceItem", order_items[i].sku, order_items[i].name, order_items[i].category, order_items[i].price, order_items[i].quantity]);
}
_paq.push(["trackEcommerceOrder", order.id, order.revenue, order.subtotal, order.tax, order.shippingtotal, order.discounttotal]);
_paq.push(["trackPageView"]);
}
})();
</script>
Tag: Makaira Tracking - Kategorieübersicht, Produktdetail Page
Typ: Custom HTML
Trigger: Pages mit Detail-URL-Pattern und Kategorie-URL-Pattern oder ProductDetailView & ProductImpression - Custom Events
<script type="text/javascript">
(function() {
var trackView = false;
var arg1, arg2, arg3;
if (typeof window._paq === 'object') {
switch ({{DLV - pageType}}) {
case ('category'):
var cat = {{DLV - category}};
arg1 = false;
arg2 = false;
arg3 = cat;
trackView = true;
break;
case ('product'):
var prod = {{DLV - product}};
arg1 = prod.sku;
arg2 = prod.name;
arg3 = prod.brand;
trackView = true;
break;
}
if (trackView) {
_paq.push(['setEcommerceView', arg1, arg2, arg3]);
_paq.push(['trackPageView']);
}
}
})();
</script>
Tag: Site Search Tag
Typ: Custom HTML
Trigger: Pages mit Suchseiten-URL-Pattern oder SearchResultView - Custom Event
<script type="text/javascript">
(function() {
var trackView = false;
var arg1, arg2, arg3;
if (typeof window._paq === 'object') {
switch ({{DLV - pageType}}) {
case ('searchresults'):
arg1 = {{DLV - search.searchTerm}};
arg2 = false;
arg3 = {{DLV - search.resultCount}};
trackView = true;
break;
}
if (trackView) {
_paq.push(['deleteCustomVariables', 'page']);
_paq.push(['trackSiteSearch', arg1, arg2, arg3]);
_paq.push(['trackPageView']);
}
}
})();
</script>