function humanDetails($machine, $entity = null) { $humanSpeak = ''; switch ($machine) { case 'TRACK_PAGEVIEW': $humanSpeak = '<td>This tag will track pageviews.'; //Universal Pageview $fields = getParamList($entity, 'fieldsToSet'); if ($fields !== '' && count($fields) > 0) { foreach ($fields as $fieldVal) { if ($fieldVal['map']['0']['value'] === 'page') { $humanSpeak = $humanSpeak . '<br />This tag is setup to handle virtual pageviews using ' . variablise($fieldVal['map'][1]['value'], $entity, true) . ' as the virtual page path.'; } } } //Classic Pageview $entityDeets = $entity['parameter']; if ($entityDeets !== null && count($entityDeets) > 0) { foreach ($entityDeets as $edKey => $edVal) { if (array_key_exists('key', $entityDeets[$edKey]) && $entityDeets[$edKey]['key'] === 'page') { $humanSpeak = $humanSpeak . '<br />This tag is setup to handle virtual pageviews using ' . variablise($entityDeets[$edKey]['value'], $entity, true) . ' as the virtual page path.'; } } } break; case 'TRACK_EVENT': $humanSpeak = '<td>This tag will track events using the following details:'; $eCat = getParam($entity, 'eventCategory'); $eAct = getParam($entity, 'eventAction'); $eLab = getParam($entity, 'eventLabel'); $eVal = getParam($entity, 'eventValue'); $eInt = getParam($entity, 'nonInteraction'); $humanSpeak = $humanSpeak . '<table class="table table-bordered table-striped">'; if ($eCat !== null && $eCat !== '') { $humanSpeak = $humanSpeak . '<tr><th>Event Category</th><td>' . variablise($eCat, $entity, true) . '</td></tr>'; } if ($eAct !== null && $eAct !== '') { $humanSpeak = $humanSpeak . '<tr><th>Event Action</th><td>' . variablise($eAct, $entity, true) . '</td></tr>'; } if ($eLab !== null && $eLab !== '') { $humanSpeak = $humanSpeak . '<tr><th>Event Label</th><td>' . variablise($eLab, $entity, true) . '</td></tr>'; } if ($eVal !== null && $eVal !== '') { $humanSpeak = $humanSpeak . '<tr><th>Event Value</th><td>' . variablise($eVal, $entity, true) . '</td></tr>'; } if ($eInt === null || $eInt == 'false') { $humanSpeak = $humanSpeak . '<tr><td></td><td>This is an interactive Event.<br />It will affect the bounce status of the session.<br />It will affect session duration and time on page metrics.<br />It will appear in real-time reports.</td></tr>'; } else { if ($eInt !== 'true') { $humanSpeak = $humanSpeak . '<tr><td>Interaction determined by:</td><td>' . variablise($eInt, $entity, true) . '</td></tr>'; } else { $humanSpeak = $humanSpeak . '<tr><td></td><td>This is a NON-interactive Event.<br />It won\'t affect the bounce status of the session.<br />It won\'t affect session duration or time on page metrics.<br />It won\'t appear in real-time reports.</td></tr>'; } } $humanSpeak = $humanSpeak . '</table></td>'; break; case 'TRACK_TIMING': $humanSpeak = '<td>This tag will measure periods of time.<br />These could be anything from downloading jQuery on the page to the time it takes a user to click a link or button.<br />This is a very flexible tag type and likely involves developers to make it work.<br /><br />The details of the timing event are:'; $tVar = getParam($entity, 'timingVar'); $tCat = getParam($entity, 'timingCategory'); $tVal = getParam($entity, 'timingValue'); $tLab = getParam($entity, 'timingLabel'); $humanSpeak = $humanSpeak . '<table class="table table-bordered table-striped">'; if ($tVar !== null && $tVar !== '') { $humanSpeak = $humanSpeak . '<tr><th>Timing Variable</th><td>' . variablise($tVar, $entity, true) . '</td></tr>'; } if ($tCat !== null && $tCat !== '') { $humanSpeak = $humanSpeak . '<tr><th>Timing Category</th><td>' . variablise($tCat, $entity, true) . '</td></tr>'; } if ($tVal !== null && $tVal !== '') { $humanSpeak = $humanSpeak . '<tr><th>Timing Value</th><td>' . variablise($tVal, $entity, true) . '</td></tr>'; } if ($tLab !== null && $tLab !== '') { $humanSpeak = $humanSpeak . '<tr><th>Timing Label</th><td>' . variablise($tLab, $entity, true) . '</td></tr>'; } $humanSpeak = $humanSpeak . '</table></td>'; break; case 'TRACK_TRANSACTION': $humanSpeak = '<td>This tag will track transactions.<br />Make sure your developers have put the transaction data in the "dataLayer" on the correct transaction (Thank You) page.</td>'; break; case 'TRACK_SOCIAL': $humanSpeak = '<td>This tag will track social interactions: Likes, Follows, Shares.<br />These actions normally happen when Social Network buttons are clicked by the user.</td>'; break; case 'DECORATE_LINK': $humanSpeak = '<td>This tag is used to "decorate" links for use in Cross Domain Tracking.<br />This is technical and something your developers will control.</td>'; break; case 'DECORATE_FORM': $humanSpeak = 'This tag is used to "decorate" forms for use in Cross Domain Tracking.<br />This is technical and something your developers will control.'; break; } return $humanSpeak; }
function getDetailsforFls($tag) { $whatItDoes = ''; $countingRaw = ''; $countingEn = ''; $customVars = []; $whatItDoes = $whatItDoes . '<td>The DoubleClick Floodlight Sales tag allows you to keep track of how many items users have purchased, as well as the total value of those purchases.<table class="table table-bordered table-striped">'; //Advertiser ID $whatItDoes = $whatItDoes . '<tr><th>The Advertiser ID is</th><td>' . variablise(getParam($tag, 'advertiserId'), $tag, true) . '</td></tr>'; //Group Tag String $whatItDoes = $whatItDoes . '<tr><th>The Group Tag String is</th><td>' . variablise(getParam($tag, 'groupTag'), $tag, true) . '</td></tr>'; //Activity Tag $deetwhatItDoess = $whatItDoes . '<tr><th>The Activity Tag String is</th><td>' . variablise(getParam($tag, 'activityTag'), $tag, true) . '</td></tr>'; //Counting Method $countingRaw = getParam($tag, 'countingMethod'); switch ($countingRaw) { case 'ITEM_SOLD': $countingEn = 'Item Sold'; break; case 'TRANSACTIONS': $countingEn = 'Transactions'; break; } $whatItDoes = $whatItDoes . '<tr><th>The Counting Method is</th><td>' . $countingEn . '</td></tr>'; if (getParam($tag, 'revenue') !== '' || getParam($tag, 'orderId') !== '' || getParam($tag, 'quantity') !== '') { $whatItDoes = $whatItDoes . '<tr><th>Unique Parameters</th><td><table class="table table-bordered table-striped">'; if (getParam($tag, 'revenue') !== '') { $whatItDoes = $whatItDoes . '<tr><th>Revenue</th><td>' . variablise(getParam($tag, 'revenue'), $tag, true) . '</td></tr>'; } if (getParam($tag, 'orderId') !== '') { $whatItDoes = $whatItDoes . '<tr><th>OrderId</th><td>' . variablise(getParam($tag, 'orderId'), $tag, true) . '</td></tr>'; } if (getParam($tag, 'quantity') !== '') { $whatItDoes = $whatItDoes . '<tr><th>Quantity</th><td>' . variablise(getParam($tag, 'quantity'), $tag, true) . '</td></tr>'; } $whatItDoes = $whatItDoes . '</table></td></tr>'; } if (getParam($tag, 'U') !== '' || getParam($tag, 'Tran') !== '') { $whatItDoes = $whatItDoes . '<tr><th>Standard Variables</th><td><table class="table table-bordered table-striped">'; if (getParam($tag, 'U') !== '') { $whatItDoes = $whatItDoes . '<tr><th>U</th><td>' . variablise(getParam($tag, 'U'), $tag, true) . '</td></tr>'; } if (getParam($tag, 'Tran') !== '') { $whatItDoes = $whatItDoes . '<tr><th>Tran</th><td>' . variablise(getParam($tag, 'Tran'), $tag, true) . '</td></tr>'; } $whatItDoes = $whatItDoes . '</table></td></tr>'; } //Custom Variables $customVars = getParamList($tag, 'customVariable'); if ($customVars !== null && $customVars !== '' && count($customVars) > 0) { $whatItDoes = $whatItDoes . '<tr><th>Custom Variables:</th><td>'; $whatItDoes = $whatItDoes . '<table class="table table-bordered table-striped">'; foreach ($customVars as $cvKey => $cvVal) { $whatItDoes = $whatItDoes . '<tr><td>' . $cvVal['map'][0]['value'] . '</td>'; $whatItDoes = $whatItDoes . '<td>' . variablise($cvVal['map'][1]['value'], $tag, true) . '</td></tr>'; } $whatItDoes = $whatItDoes . '</table></td></tr>'; } //Image tag if (getParam($tag, 'useImageTag') === 'true') { $whatItDoes = $whatItDoes . '<tr><th>The tag uses an image tag</th><td></td></tr>'; } $whatItDoes = $whatItDoes . '</table></td></tr>'; return getGeneralDetails($tag, 'This is a Double Click Floodlight Sales tag.', $whatItDoes); }
function udvDetail($udv, $typeString = '', $usage = '') { $attributeName = ''; $selectorType = ''; $deets = '<h3>Details for User-defined variable <i>' . $udv['name'] . '</i></h3>'; $deets = $deets . '<a href="https://tagmanager.google.com/#/container/accounts/' . $udv['accountId'] . '/containers/' . $udv['containerId'] . '/variables/' . $udv['variableId'] . '"'; $deets = $deets . ' style="position:relative;float:right;top:-40px;right:10px;" class="udvEdit">edit</a>'; $deets = $deets . '<table class="table table-bordered table-striped">'; $deets = $deets . '<tr><th>Name</th><td>' . $udv['name'] . '</td></tr>'; $deets = $deets . '<tr><th>What it\'s for</th><td>' . $typeString . '</td></tr>'; $deets = $deets . '<tr><th>What it does</th>'; $deets = $deets . '<td>' . $usage; if ($udv['type'] === 'd') { if (getParamTemplate($udv, 'attributeName') !== '') { $attributeName = array_key_exists('value', getParamTemplate($udv, 'attributeName')) ? getParamTemplate($udv, 'attributeName')['value'] : ''; } if (getParamTemplate($udv, 'selectorType') !== '') { $selectorType = array_key_exists('value', getParamTemplate($udv, 'selectorType')) ? getParamTemplate($udv, 'selectorType')['value'] : ''; } if ($selectorType !== '') { $selectorType = getParamTemplate($udv, 'selectorType')['value']; if ($selectorType === 'CSS') { $elementSelector = getParamTemplate($udv, 'elementSelector')['value']; $deets = $deets . '<br /><br />This variable will extract the "<b>' . variablise($attributeName, $udv) . '</b>" attribute from the first element on the page that matches the CSS selector "<b>' . variablise($elementSelector, $udv) . '</b>".<br /><br />'; $deets = $deets . '<b>Warning</b>: This is not supported in IE7. IE8 and only supports CSS 2.1 selectors.<br />'; } if ($selectorType === 'ID') { $elementId = getParamTemplate($udv, 'elementId')['value']; $deets = $deets . '<br /><br />This variable will extract the "<b>' . variablise($attributeName, $udv) . '</b>" attribute from the first element on the page with the ID "<b>' . variablise($elementId, $udv) . '</b>".<br /><br />'; $deets = $deets . 'Of course, there should only be one element with this ID so if there are multiple elements with the same ID, have a word with your front-end development team.<br />'; } } } if ($udv['type'] === 'aev') { $varType = getParamTemplate($udv, 'varType')['value']; $hostSource = 'Element URL'; switch ($varType) { case 'ELEMENT': $deets = $deets . 'The variable returns the value of the "gtm.element" key on the data layer. If populated by an Auto-Event, the result will be the DOM element that triggered the event.<br /><br />In other words, the <i>thing</i> on the page that was clicked or the form that was submitted.<br /><br />'; break; case 'ATTRIBUTE': $deets = $deets . 'The variable returns the value of the "' . getParamTemplate($udv, 'attribute')['value'] . '" attribute for the element that triggered the last click or form submit event.<br /><br /><br />'; break; case 'CLASSES': $deets = $deets . 'The variable returns the value of the "gtm.elementClasses" key on the data layer. If populated by an Auto-Event, the result will be the "class" attribute of the DOM element that triggered the event (the <i>thing</i> that was clicked or the form that was submitted).<br /><br />'; break; case 'ID': $deets = $deets . 'The variable returns the value of the "gtm.elementId" key on the data layer. If populated by an Auto-Event, the result will be the "id" attribute of the DOM element that triggered the event (the <i>thing</i> that was clicked or the form that was submitted).<br /><br />'; break; case 'TARGET': $deets = $deets . 'The variable returns the value of the "gtm.elementTarget" key on the data layer. If populated by an Auto-Event, the result will be the "target" attribute of the DOM element that triggered the event (the <i>thing</i> that was clicked or the form that was submitted).<br /><br />'; break; case 'TEXT': $deets = $deets . 'The variable returns the value of the "gtm.element" key on the data layer and its text content if there is any.<br />If populated by a click or link-click Auto-Event, the text content will be the "innerText" or the "textContent" attribute of the DOM element that triggered the event.<br /><b>Technical:</b> The text will be trimmed and normalised (white-spaces will be consolidated) to account for browsers variations.<br /><br />'; break; case 'URL': $deets = $deets . 'The variable returns the value of the "gtm.elementUrl" key on the data layer.<br />If populated by an Auto-Event, the result will be the "href" or "action" attribute of the DOM element that triggered the event, depending on the type of element (the <i>thing</i> that was clicked or the form that was submitted).<br /><br />'; $URLComponent = getParamTemplate($udv, 'component') !== '' ? getParamTemplate($udv, 'component')['value'] : ''; if ($URLComponent !== '') { switch ($URLComponent) { case 'HOST': $deets = $deets . 'The "hostname" part of the ' . $hostSource; if (getParam($udv, 'stripWww') !== null && getParam($udv, 'stripWww') === 'true') { $deets = $deets . ' - minus the www part - '; } $deets = $deets . ' will be returned.<br />'; break; case 'PATH': $deets = $deets . 'The path of the ' . $hostSource . ' will be returned.<br />'; if (strlen(getParamList($udv, 'defaultPages')) > 0) { $deets = $deets . 'The list of default pages to ignore is:<ul>'; $defaultPages = getParamList($udv, 'defaultPages'); foreach ($defaultPages as $defPageIndex => $defPageVal) { $deets = $deets . '<li>' . $defaultPages[$defPageIndex]['value'] . '</li>'; } $deets = $deets . '</ul><br />'; $deets = $deets . 'The last non-directory segment in the path will be stripped if it matches any of the default pages. For instance, if a default page is "index.html" and the URL is "http://a.com/x/index.html", the variable value will be "/x/".<br />'; } break; case 'QUERY': $queryKey = ''; if (getParamTemplate($udv, 'queryKey') !== '') { $queryKey = variablise(getParamTemplate($udv, 'queryKey')['value'], $udv); } $deets = $deets . 'The value of the querystring variable (the part after the ? on the ' . $hostSource . ') "' . $queryKey . '" will be returned.<br />'; break; case 'FRAGMENT': $deets = $deets . 'The fragment (the part after the # on the ' . $hostSource . ') will be returned.<br />'; break; case 'PORT': $deets = $deets . 'The port (80 or 443 for example) of the ' . $hostSource . ' will be returned.<br />'; break; case 'PROTOCOL': $deets = $deets . 'The protocol (http or https) of the ' . $hostSource . ' will be returned.<br />'; break; case 'URL': $deets = $deets . 'The full URL of the ' . $hostSource . ' will be returned.<br />'; break; } } break; case 'HISTORY_NEW_URL_FRAGMENT': $deets = $deets . 'The value is determined by reading the "gtm.newUrlFragment" key from the data layer. If populated by an Auto-Event, the result will be the new URL fragment set on a history change event (Used by AJAX forms - <b>Technical</b>).<br />'; break; case 'HISTORY_OLD_URL_FRAGMENT': $deets = $deets . 'The value is determined by reading the "gtm.oldUrlFragment" key from the data layer. If populated by an Auto-Event, the result will be the old URL fragment set on the previous history change event (Used by AJAX forms - <b>Technical</b>).<br />'; break; case 'HISTORY_NEW_STATE': $deets = $deets . 'The value is determined by reading the "gtm.newHistoryState" key from the data layer. If populated by an Auto-Event, the result will be the new history state set on a history change event (Used by AJAX forms - <b>Technical</b>).<br />'; break; case 'HISTORY_OLD_STATE': $deets = $deets . 'The value is determined by reading the "gtm.oldHistoryState" key from the data layer. If populated by an Auto-Event, the result will be the old history state set on the previous history change event (Used by AJAX forms - <b>Technical</b>).<br />'; break; case 'HISTORY_CHANGE_SOURCE': $deets = $deets . 'The value is determined by reading the "gtm.historyChangeSource" key from the data layer. If populated by an Auto-Event, the result will be the source of the gtm.historyChange event, which can be: "popstate", "pushState", "replaceState" or "polling" (Used by AJAX forms - <b>Technical</b>).<br />'; break; } } if ($udv['type'] === 'k') { if (getParam($udv, 'decodeCookie') === 'true') { $deets = $deets . "<br /><br />The value of the cookie will be URI-decoded. This is a nice thing to do to make your data human readable.<br />"; } else { $deets = $deets . "<br /><br />The value of the cookie will not be URI-decoded.<br />"; $deets = $deets . "If enabled, the value of the cookie 'xxx%3Dyyy' would become 'xxx=yyy'.<br />"; $deets = $deets . "This might be a nice thing to do to make your data human readable.<br />"; } } if ($udv['type'] === 'f') { if (array_key_exists('parameter', $udv)) { $component = getParam($udv, 'component'); if ($component === 'QUERY' || $component === 'FRAGMENT') { $deets = $deets . 'It returns the ' . translateToHuman($component, $udv) . ' part of the referring page URL using the '; if ($component === 'QUERY') { $deets = $deets . getParam($udv, 'queryKey') . ' querystring parameter.<br />'; } else { $deets = $deets . ' part of the URL after the "#" without the leading "#".<br />'; } } else { $deets = $deets . 'It returns the ' . translateToHuman($component, $udv) . ' the user just came from.<br />'; } if (getParam($udv, 'stripWww') === 'true') { $deets = $deets . 'The returned value will have the "www" part of the hostname stripped off.'; } } else { $deets = $deets . 'It returns the full URL of the last page the user was on.<br /><br />'; $deets = $deets . 'Why not just use the \'Referrer\' built in variable? It does the same thing.'; } } if ($udv['type'] === 'u') { $hostSource = 'URL'; $URLComponent = getParamTemplate($udv, 'component')['value']; $hostSource = getParamTemplate($udv, 'customUrlSource') !== '' ? translateToHuman(getParamTemplate($udv, 'customUrlSource')['value'], $udv) : $hostSource; switch ($URLComponent) { case 'HOST': $deets = $deets . 'The "hostname" part of the ' . $hostSource; if (getParam($udv, 'stripWww') !== null && getParam($udv, 'stripWww') === 'true') { $deets = $deets . ' - minus the www part - '; } $deets = $deets . ' will be returned.<br />'; break; case 'PATH': $deets = $deets . 'The path of the ' . $hostSource . ' will be returned.<br />'; if (strlen(getParamList($udv, 'defaultPages')) > 0) { $deets = $deets . 'The list of default pages to ignore is:<ul>'; $defaultPages = getParamList($udv, 'defaultPages'); foreach ($defaultPages as $defPageIndex => $defPageVal) { $deets = $deets . '<li>' . $defaultPages[$defPageIndex]['value'] . '</li>'; } $deets = $deets . '</ul><br />'; } break; case 'QUERY': $queryKey = ''; if (getParamTemplate($udv, 'queryKey') !== '') { $queryKey = variablise(getParamTemplate($udv, 'queryKey')['value'], $udv); } $deets = $deets . 'The value of the querystring variable (the part after the ? on the ' . $hostSource . ') "' . $queryKey . '" will be returned.<br /><br />'; break; case 'FRAGMENT': $deets = $deets . 'The fragment (the part after the # on the ' . $hostSource . ') will be returned.<br />'; break; case 'PORT': $deets = $deets . 'The port (80 or 443 for example) of the ' . $hostSource . ' will be returned.<br />'; break; case 'PROTOCOL': $deets = $deets . 'The protocol (http or https) of the ' . $hostSource . ' will be returned.<br />'; break; case 'URL': $deets = $deets . 'The full URL of the ' . $hostSource . ' will be returned.<br />'; break; } } if ($udv['type'] === 'smm') { $deets = $deets . 'The <i>input</i> variable for the lookup table is ' . variablise(getParamTemplate($udv, 'input')['value'] . '.<br /><br />', $udv); $deets = $deets . '<table class="table table-bordered table-striped"><tr><th>' . variablise(getParamTemplate($udv, 'input')['value'] . '', $udv) . '</th><th>Returned value</th></tr>'; $lookup = getParamList($udv, 'map'); foreach ($lookup as $lRow => $lRowVal) { $deets = $deets . '<tr><td>' . variablise($lookup[$lRow]['map'][0]['value'], $udv) . '</td>'; $deets = $deets . '<td>' . variablise($lookup[$lRow]['map'][1]['value'], $udv) . '</td></tr>'; } $deets = $deets . '</table>'; if (getParamTemplate($udv, 'defaultValue') !== '' && getParamTemplate($udv, 'defaultValue') !== null) { $deets = $deets . 'The default value returned if no matches are found in the table is "' . variablise(getParamTemplate($udv, 'defaultValue')['value'], $udv) . '".<br />'; } } if ($udv['type'] === 'jsm') { $varRefs = ''; $rawJS = getParam($udv, 'javascript'); $varRefs = getVarRefs($rawJS, $udv); findPushyVars($udv); if ($varRefs !== '') { $deets = $deets . 'Variables referenced in this variable:<br />' . $varRefs; } if ($rawJS !== '') { $deets = $deets . '<p style="margin:5px;"><textarea class="form-control" rows="10" cols="60" disabled="disabled">' . $rawJS . '</textarea></p><br />'; } } if ($udv['type'] !== 'c' && $udv['type'] !== 'smm') { $deets = $deets . defaultValue($udv); } $deets = $deets . '<tr><th>Where it\'s used</th>'; $deets = $deets . getUsage($udv); $deets = $deets . '<tr><th>Where it lives</th>'; if (array_key_exists('parentFolderId', $udv)) { $deets = $deets . '<td>' . folderisation($udv['parentFolderId'], 'User Defined Variable') . '</td></tr>'; } else { $deets = $deets . '<td>' . folderisation(null, 'User Defined Variable') . '</td></tr>'; } $deets = $deets . '</table>'; return $deets; }
function getVarRefs($raw, $entity) { global $usedUdvs; $varRefRe = "/{{.*?}}/"; $varArray = []; $varDeets = ''; if (strpos($raw, '{{')) { preg_match_all($varRefRe, $raw, $varArray); foreach ($varArray[0] as $matchIndex => $matchVal) { $varDeets = $varDeets . '<li>' . variablise($varArray[0][$matchIndex], $entity) . '</li>'; //remember something has used the variable. if (array_search($varArray[0][$matchIndex], $usedUdvs) === false) { array_push($usedUdvs, $varArray[0][$matchIndex]); } } if ($varDeets !== '') { $varDeets = '<ul>' . $varDeets . '</ul><br />'; } } return $varDeets; }
function waitAndValidate($trig, $action) { $wvDeets = ''; if ($trig['waitForTags']['value'] == 'true') { $wvDeets = $wvDeets . 'When a user ' . $action . 's, the website will wait for '; if (strpos($trig['waitForTagsTimeout']['value'], '{') === false) { $wvDeets = $wvDeets . 'up to ' . $trig['waitForTagsTimeout']['value'] / 1000 . ' seconds'; } else { $wvDeets = $wvDeets . 'the number of seconds specified by the ' . variablise($trig['waitForTagsTimeout']['value'], $trig) . ' variable '; } $wvDeets = $wvDeets . ' before going to the next page.<br /><br />'; } if ($trig['checkValidation']['value'] == 'true') { $wvDeets = $wvDeets . 'When a user ' . $action . 's, tags will only fire if the ' . $action . ' is considered a <i>valid</i> action.<br />'; } return $wvDeets; }