Skip to content

Nau-media-AG/impact-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Impact Helper Script

Usage

Recommended Method

The preferred way to include the Impact helper script is to reference it directly from the Impact CDN:

<script src="https://impact.naudata.ch/embed"></script>

This ensures you always have the latest version with automatic updates and optimal performance.

Alternative Method (Not Recommended)

If you need to self-host the script, you can copy the following code and include it in your project. However, this method is not recommended because:

  • You won't receive automatic updates
  • You're responsible for manually updating the script
  • You may miss important bug fixes and new features
<script>
(() => {
  const load = async (doc, clicktag, campaign) => {
    try {
      const res = await fetch(
        `https://impact.naudata.ch/${campaign}?b=${(() => {
          let a = navigator.userAgent;
          let i = a.indexOf("Chrome/");
          if (i < 0) return "c";
          let o = a.indexOf(" ", i);
          const c = a.substring(i + 7, o);
          return parseInt(c) >= 115 ? "m" : "c";
        })()}`,
      );
      const script = doc.createElement("script");
      script.setAttribute("type", "module");
      script.dataset["clicktag"] = clicktag;
      script.id = "nau-videohead";
      script.innerHTML = await res.text();
      doc.head.appendChild(script);
    } catch (err) {
      console.error(err);
      console.error(2);
    }
  };
  const mount = () => {
    try {
      const doc = window.top.document;
      window.addEventListener("message", (data) => {
        if (data?.data?.type !== "nau-v-show") return;
        window._nau_vid_frame = data.source;
        load(doc, data.data.clicktag, data.data.campaign);
      });
      console.log("embed");
    } catch (err) {
      console.error(err);
      console.log("embed crash");
    }
  };

  mount();
})();
</script>

Support

For questions or support regarding the Impact analytics platform, please contact Nau Media AG.

About

Daily helper script from impact.naudata.ch

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published