GTM

function () {
 return {{Click Text}}.toLowerCase();
 }
function () {
var content = document.body.innerText;
var query="Search Query";
if (content.search(query) > -1 ) {
 return true;
} else {
 return false;
}
}
function () { 
if ({{form field}} == '' || {{form field}} == null ) { 
return false; 
} else { 
return true; 
}
}
function () {
 return trim({{Click Element}}.parentNode.innerText);
}
function () { 
 var value={{Click Classes}}.split(" "); 
 return value[1]; 
 }
<script>
window.dataLayer = window.dataLayer || []
dataLayer.push({
   'transactionId': '1234',
   'transactionAffiliation': 'Acme Clothing',
   'transactionTotal': 38.26,
   'transactionTax': 1.29,
   'transactionShipping': 5,
   'transactionProducts': [{
       'sku': 'DD44',
       'name': 'T-Shirt',
       'category': 'Apparel',
       'price': 11.99,
       'quantity': 1
   },{
       'sku': 'AA1243544',
       'name': 'Socks',
       'category': 'Apparel',
       'price': 9.99,
       'quantity': 2
   }]
});
</script>
function() {
var width = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
return width;
}
<script>
  (function() {
    
    // Change the CSS selector in the parenthesis to match your select menu
    var selectMenu = document.querySelector('select#selectMenu');
    
    var callback = function(e) {
      var selectedOption = e.target.options[e.target.selectedIndex];
      window.dataLayer.push({
        event: 'selectionMade',
        selectedElement: selectedOption
      });
    };
    
    selectMenu.addEventListener('change', callback, true);
  })();
</script>
function ()
{
 var min = 1; //edit the minimum possible value
 var max = 5; //edit the maximum possible value
 return Math.floor(Math.random()*(max-min+1)+min);
}
function(){
 var searchEngines = ['www.google', 'www.bing', 'www.yandex', 'search.yahoo', 'duckduckgo', 'www.ask', 'www.search', 'www.info', 'www.baidu', 'search.aol', 'www.dogpile'];
 var referrerHostname = document.referrer.split('/')[2]; 
 var shortenedHostname = referrerHostname.substr(0, referrerHostname.lastIndexOf("."));
 var indexOfSearchEngines = searchEngines.indexOf(shortenedHostname); 
 if (indexOfSearchEngines > -1){
  return true;
 } else {
  return false;
 }
}

Similiar Collections