Advertisement
NikolayBezay

GTM tag to trigger click to call form for PMI PT(Updated! 02.05.2023).

Apr 20th, 2023 (edited)
762
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.15 KB | None | 0 0
  1. <script>
  2. (function (a, d, o, r, i, c, u, p, w, m) {
  3. m = d.getElementsByTagName(o)[0], a[c] = a[c]
  4. || {}, a[c].trigger = a[c].trigger || function () {
  5. (a[c].trigger.arg = a[c].trigger.arg || []).push(arguments)},
  6. a[c].on = a[c].on || function () {(a[c].on.arg = a[c].on.arg || []).push(arguments)},
  7. a[c].off = a[c].off || function () {(a[c].off.arg = a[c].off.arg || []).push(arguments)
  8. }, w = d.createElement(o), w.id = i, w.src = r, w.async = 1, w.setAttribute(p, u),
  9. m.parentNode.insertBefore(w, m), w = null}
  10. )(window, document, "script", "https://20787126.adoric-om.com/adoric.js", "Adoric_Script", "adoric","717f6b771a368c0db0b6de40944408ed", "data-key");
  11. </script>
  12.  
  13. <script>
  14. (function() {
  15.     function getCookie(cname) {
  16.         var name = cname + "=";
  17.         var decodedCookie = decodeURIComponent(document.cookie);
  18.         var ca = decodedCookie.split(';');
  19.         for (var i = 0; i < ca.length; i++) {
  20.            var c = ca[i];
  21.            while (c.charAt(0) == ' ') {
  22.                c = c.substring(1);
  23.            }
  24.            if (c.indexOf(name) == 0) {
  25.                return c.substring(name.length, c.length);
  26.            }
  27.        }
  28.        return "";
  29.    }
  30.    function triggerCampaignWithDellay() {
  31.        var isAgeGateAcepted = getCookie('iqos-age-verified');
  32.        if (!isAgeGateAcepted) {
  33.            return null;
  34.        }
  35.        var DELLAY_TIME = 30 * 1000; /*30 seconds*/
  36.        setTimeout(function() {
  37.            if (adoric && adoric.trigger) {
  38.                adoric.trigger('showClickToCallForm');
  39.            }
  40.        }, DELLAY_TIME);
  41.    }
  42.  
  43.    function checkPageCondition() {
  44.        var isAgeGateButtonExist = document.querySelector('#age-gate-check');
  45.        if (isAgeGateButtonExist) {
  46.            isAgeGateButtonExist.addEventListener('click', function() {
  47.                setTimeout(triggerCampaignWithDellay, 400);
  48.            });
  49.        } else {
  50.            triggerCampaignWithDellay();
  51.        }
  52.    }
  53.  
  54.    if (document.readyState === 'loading') {
  55.        document.addEventListener('DOMContentLoaded', checkPageCondition);
  56.    } else {
  57.        checkPageCondition();
  58.    }
  59. })();    
  60. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement