sein Name war Jockel
sein Titel von der Autobahn
JOCKEL VON DER AUTOBAHN
athina src=" // Require the necessary APIs const addEventCallback = require('addEventCallback'); const readFromDataLayer = require('copyFromDataLayer'); const sendPixel = require('sendPixel'); const getTimestamp = require('getTimestamp'); const getUrl = require('getUrl'); const encodeUriComponent = require('encodeUriComponent'); const generateRandom = require('generateRandom'); // Get the dataLayer event that triggered the tag const event = readFromDataLayer('event'); const eventTimestamp = getTimestamp(); // used for eventlabel, transaction id, anti-cache const uaCode = data.uaCode; const batchHits = data.batchHits === 'yes'; const maxTags = data.maxTags; const hostName = getUrl('host'); // used for product category, affiliation const pathName = encodeUriComponent(getUrl('path')); const fullHost = getUrl(); // location field const eventLabel = data.customEventLabel ? data.customEventLabel : eventTimestamp; const clientId = data.clientId ? data.clientId : eventTimestamp +' '+ generateRandom(1,999); // measurement protocol prep let endPoint = 'https://www.google-analytics.com/collect?z=' + eventTimestamp + '&v=1' + '&tid=' + uaCode + '&cid=' + clientId + '&t=event' + '&dp=' + pathName + '&dh=' + hostName + '&dl=' + encodeUriComponent(fullHost) + '&pa=purchase' + '&ta=' + hostName + // affiliation '&ec=gtm_monitor' ; let eventValue = 0; // Utility for splitting an array into multiple arrays of given size const splitToBatches = (arr, size) => { const newArr = []; for (let i = 0, len = arr.length; i < len; i += size) { newArr.push(arr.slice(i, i + size)); } return newArr; }; // The addEventCallback gets two arguments: container ID and a data object with an array of tags that fired addEventCallback((ctid, eventData) => { // Filter out the monitoring tag itself const tags = eventData.tags.filter(t => t.exclude !== 'true'); // If batching is enabled, split the tags into batches of the given size const batches = batchHits ? splitToBatches(tags, maxTags) : [tags]; // For each batch, build a payload and dispatch to the endpoint as a GET request batches.forEach(tags => { let payload = '&ea=' + encodeUriComponent(event) + '&ti=' + eventTimestamp + '&el=' + eventLabel; tags.forEach((tag, idx) => { eventValue = eventValue + 1; const tagPrefix = '&pr' + (idx + 1); let tagName = tag.name ? tag.name : 'unnamed tag with ID: ' + tag.id; payload += tagPrefix + 'id=' + tag.id + // SKU tagPrefix + 'nm=' + encodeUriComponent(tagName) + // product name tagPrefix + 'va=' + tag.status + // variant tagPrefix + 'ca=' + event + // category tagPrefix + 'br=' + pathName + // brand tagPrefix + 'qt=1' + // quantity = 1 tagPrefix + 'pr=' + tag.executionTime + ".00"; // time = money }); payload += '&tr=' + eventValue + ".00" + // trans.revenue = nr of prods '&ev=' + eventValue; // event value = nr of products sendPixel(endPoint + payload, null, null); }); }); // After adding the callback, signal tag completion data.gtmOnSuccess(); "