hupspot埋点&嵌入D365窗体

<!-- Google tag (gtag.js) -->
<script>
     var _hsp = window._hsp = window._hsp || [];
  debugger;
    _hsp.push(['addPrivacyConsentListener', (consent) => {
    if (consent.categories.analytics) {
        const script = document.createElement('script');
          script.src = "https://www.googletagmanager.com/gtag/js?id=G-DQHBQT85CC";
          script.async = 'true'
          document.head.appendChild(script)
      }
    }])
</script>
<script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    gtag('config', 'G-DQHBQT85CC');
</script>



<script>
  
  
  window.onload = function () {
    let T =setTimeout(() => {
      insertIframe();
      clearTimeout(T);
    }, 1000);
  };
  function getCookie(name) {
    const value = `; ${document.cookie}`;
    const parts = value.split(`; ${name}=`);
    if (parts.length === 2) return parts.pop().split(";").shift();
  }

  //getCookie("hubspotutk");
  //在body上插入iframe
  function insertIframe() {
    const iframe = document.createElement("iframe");
    iframe.style.width = "100%";
    iframe.style.height = "1000px";
    iframe.style.border = "none";
    let userToken = getCookie("hubspotutk");
    let url =
      "https://assets-eur.mkt.dynamics.com/e52951bd-6549-ee11-be6a-000d3a486d54/digitalassets/standaloneforms/632b5653-1d7b-ef11-ac20-000d3a443cee?userToken=" +
      userToken;
    iframe.src = url;
    document.body.appendChild(iframe);
    //return iframe;
  }

  
</script>

 

posted @ 2025-04-21 17:29  溜溜球_小钢wan  阅读(9)  评论(0)    收藏  举报