Advertisement
bheng8200

Tealium (Pendo) default

Jun 27th, 2023
538
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //~~tv:16053.20181129
  2. //~~tc: Adding tag Pendo.io
  3.  
  4. var pendo = window["pendo"] = window["pendo"] || {};
  5. pendo._q = [];
  6.  
  7. //tealium universal tag - utag.sender.16053 ut4.0.##UTVERSION##, Copyright ##UTYEAR## Tealium.com Inc. All Rights Reserved.
  8. try {
  9.   (function (id, loader) {
  10.     var u = {"id" : id};
  11.     utag.o[loader].sender[id] = u;
  12.     // Please do not modify
  13.     if (utag.ut === undefined) { utag.ut = {}; }
  14.     // Start Tealium loader 4.41
  15.     /* utag.js version 4.26 or above is required to avoid errors with this loader function */
  16.     var match = /ut\d\.(\d*)\..*/.exec(utag.cfg.v);
  17.     if (utag.ut.loader === undefined || !match || parseInt(match[1]) < 41) { u.loader = function(o, a, b, c, l, m) { utag.DB(o); a = document; if (o.type == "iframe") { m = a.getElementById(o.id); if (m && m.tagName == "IFRAME") { b = m; } else { b = a.createElement("iframe"); } o.attrs = o.attrs || {}; utag.ut.merge(o.attrs, { "height": "1", "width": "1", "style": "display:none" }, 0); } else if (o.type == "img") { utag.DB("Attach img: " + o.src); b = new Image(); } else { b = a.createElement("script"); b.language = "javascript"; b.type = "text/javascript"; b.async = 1; b.charset = "utf-8"; } if (o.id) { b.id = o.id; } for (l in utag.loader.GV(o.attrs)) { b.setAttribute(l, o.attrs[l]); } b.setAttribute("src", o.src); if (typeof o.cb == "function") { if (b.addEventListener) { b.addEventListener("load", function() { o.cb(); }, false); } else { b.onreadystatechange = function() { if (this.readyState == "complete" || this.readyState == "loaded") { this.onreadystatechange = null; o.cb(); } }; } } if (o.type != "img" && !m) { l = o.loc || "head"; c = a.getElementsByTagName(l)[0]; if (c) { utag.DB("Attach to " + l + ": " + o.src); if (l == "script") { c.parentNode.insertBefore(b, c); } else { c.appendChild(b); } } } }; } else { u.loader = utag.ut.loader; }
  18.     // End Tealium loader
  19.     // Start Tealium typeOf 4.35
  20.     if (utag.ut.typeOf === undefined) { u.typeOf = function(e) {return ({}).toString.call(e).match(/\s([a-zA-Z]+)/)[1].toLowerCase();};} else { u.typeOf = utag.ut.typeOf; }
  21.     // End Tealium typeOf
  22.  
  23.     u.ev = {"view" : 1};
  24.     u.initialized = false;
  25.     u.scriptrequested = false;
  26.     u.queue = [];
  27.  
  28.     u.map_func = function (arr, obj, item) {
  29.       var i = arr.shift();
  30.       obj[i] = obj[i] || {};
  31.       if (arr.length > 0) {
  32.         u.map_func(arr,obj[i], item);
  33.       } else {
  34.         obj[i] = item;
  35.       }
  36.     };
  37.  
  38.     u.hasOwn = function (o, a) {
  39.       return o != null && Object.prototype.hasOwnProperty.call(o, a);
  40.     };
  41.  
  42.     u.isEmptyObject = function (o, a) {
  43.       for (a in o) { if (u.hasOwn(o, a)) {return false;}} return true;
  44.     };
  45.  
  46.     u.toBoolean = function (val) {
  47.       val = val || "";
  48.       return val === true || val.toLowerCase() === "true" || val.toLowerCase() === "on";
  49.     };
  50.  
  51.     ##UTGEN##
  52.  
  53.     // Start Loader Callback
  54.     u.loader_cb = function (a, b, c) {
  55.       utag.DB("send:##UTID##:CALLBACK");
  56.       u.initialized = true;
  57.       if(u.toBoolean(u.data.send_user_data)){
  58.         var pendo_object = {}, options;
  59.         if(u.data.additional_keys.length > 0){pendo_object.additionalApiKeys = u.data.additional_keys;}
  60.         if(u.toBoolean(u.data.exclude_text)){pendo_object.excludeAllText = u.toBoolean(u.data.exclude_text);}
  61.         if(u.toBoolean(u.data.disable_guides)){pendo_object.disableGuides = u.toBoolean(u.data.disable_guides);}
  62.         if(u.toBoolean(u.data.exclude_title)){pendo_object.excludeTitle = u.toBoolean(u.data.exclude_title);}
  63.         for(options in u.data.custom){
  64.           pendo_object[options] = u.data.custom[options];
  65.         }
  66.         if(!u.isEmptyObject(u.data.visitor)){pendo_object.visitor = u.data.visitor;}
  67.         if(!u.isEmptyObject(u.data.account)){pendo_object.account = u.data.account;}
  68.         pendo.initialize(pendo_object);
  69.       }
  70.       utag.DB("send:##UTID##:CALLBACK:COMPLETE");
  71.     };
  72.     // End Loader Callback
  73.  
  74.     u.callBack = function () {
  75.       var data = {};
  76.       while (data = u.queue.shift()) {
  77.         u.data = data.data;
  78.         u.loader_cb(data.a, data.b, data.c);
  79.       }
  80.     };
  81.  
  82.     u.send = function (a, b) {
  83.       if (u.ev[a] || u.ev.all !== undefined) {
  84.         utag.DB("send:##UTID##");
  85.         utag.DB(b);
  86.  
  87.         var c, d, e, f;
  88.  
  89.         u.data = {
  90.           "qsp_delim" : "&",
  91.           "kvp_delim" : "=",
  92.           "base_url" : "https://cdn.pendo.io/agent/static/##utag_api_key##/pendo.js",
  93.           "api_key" : "##UTVARconfig_api_key##",
  94.           "additional_keys" : "##UTVARconfig_additional_keys##",
  95.           "send_user_data" : "##UTVARconfig_send_user_data##",
  96.           "visitor" : {},
  97.           "account" : {},
  98.           "exclude_text" : "",
  99.           "disable_guides" : "",
  100.           "exclude_title" : "",
  101.           "custom" : {}
  102.         };
  103.  
  104.         // Start tag-scoped extensions
  105.         ##UTEXTEND##
  106.         utag.DB("send:##UTID##:EXTENSIONS");
  107.         utag.DB(b);
  108.         // End tag-scoped extensions
  109.  
  110.         c = [];
  111.  
  112.         // Start Mapping
  113.         for (d in utag.loader.GV(u.map)) {
  114.           if (b[d] !== undefined && b[d] !== "") {
  115.             e = u.map[d].split(",");
  116.             for (f = 0; f < e.length; f++) {
  117.               var checkProp = e[f].split(".");
  118.               if (u.data.hasOwnProperty(checkProp[0])) {
  119.                 u.map_func(e[f].split("."), u.data, b[d]);
  120.               } else {
  121.                 u.data.custom[e[f]] = b[d];
  122.               }
  123.             }
  124.           }
  125.         }
  126.         utag.DB("send:##UTID##:MAPPINGS");
  127.         utag.DB(u.data);
  128.         // End Mapping
  129.  
  130.         var options = ["initialize", "identify", "updateOptions", "pageLoad"];
  131.         var w, x = options.length;
  132.         for (w = 0; w < x; ++w){
  133.             pendo[options[w]] = pendo[options[w]] || function() {pendo._q[options[w] === options[0] ? "unshift" : "push"]([options[w]].concat([].slice.call(arguments, 0)));};
  134.           }
  135.  
  136.         // Report required config is missing, and stop tag from firing.
  137.         if (!u.data.api_key) {
  138.           utag.DB(u.id + ": Tag not fired: Required attribute not populated");
  139.           return;
  140.         }
  141.  
  142.         u.data.base_url = u.data.base_url.replace("##utag_api_key##",u.data.api_key);
  143.  
  144.         if (u.initialized) {
  145.           u.loader_cb(a, b, c);
  146.         } else {
  147.           // While waiting for the external library to load, queue up all of the events with their corresponding data objects.
  148.           u.queue.push({"data" : u.data, "a" : a, "b" : b, "c" : c});
  149.           if (!u.scriptrequested) {
  150.             u.scriptrequested = true;
  151.             u.loader({
  152.               "type" : "script",
  153.               "src" : u.data.base_url,
  154.               "cb" : u.callBack,
  155.               "loc" : "script",
  156.               "id" : "utag_##UTID##",
  157.               "attrs" : {}
  158.             });
  159.           }
  160.         }
  161.         utag.DB("send:##UTID##:COMPLETE");
  162.       }
  163.     };
  164.     utag.o[loader].loader.LOAD(id);
  165.   }("##UTID##", "##UTLOADERID##"));
  166. } catch (error) {
  167.   utag.DB(error);
  168. }
  169. //end tealium universal tag
  170.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement