Untitled

 avatar
unknown
plain_text
a year ago
1.2 kB
5
Indexable
(function () {
  try {
    /* main variables */
    var debug = 0;
    var variation_name = "";
    var $;
    /* all Pure helper functions */

    function waitForElement(selector, trigger, delayInterval, delayTimeout) {
      var interval = setInterval(function () {
        if (
          document &&
          document.querySelector(selector) &&
          document.querySelectorAll(selector).length > 0
        ) {
          clearInterval(interval);
          trigger();
        }
      }, delayInterval);
      setTimeout(function () {
        clearInterval(interval);
      }, delayTimeout);
    }

    function init() {
      const target = document.querySelector('html body [id^="gform_confirmation_message"]');
      if (target.innerText.trim().includes('Thanks for contacting us!')) {
        var apiName = 'Form_Submit'; // This is the API Name for your custom event
        var purchasePrice = 1;
        intellimize.sendEvent(apiName, { value: purchasePrice });
        console.log('FormSubmitted!')
      }
    }

    waitForElement('html body [id^="gform_confirmation_message"]', init, 50, 15000);
  } catch (e) {
    if (debug) console.log(e, "error in Test" + variation_name);
  }
})();


Editor is loading...
Leave a Comment