Skip to content

Install with the script tag

Add Loomduct to any website by pasting a script into the page head.

Use the script tag on websites without a build step: marketing sites, CMSs, and any page where you can edit the HTML. For apps built with a bundler, install with npm instead.

Install with your AI agent

Add Loomduct analytics to this project. Follow the steps in https://loomduct.com/docs/install/ai-agent.md Ask me for the project token. Do not read .env files.

Before you start

  • A Loomduct project and its project token. In the dashboard, open the project menu, select Project settings, then Copy project token.

Steps

Paste the snippet into the head

Put this snippet inside <head> on every page of your site. Replace lmt_your_project_token with your project token.

index.html
<script>!function(w,n){w[n]=w[n]||{q:[]};["load","track","identify","reset","use","destroy","beforeSend","onError"].forEach(function(m){w[n][m]=w[n][m]||function(){w[n].q.length<100&&w[n].q.push([m,[].slice.call(arguments)])}})}(window,"loomduct")</script>
<script
  async
  src="https://cdn.loomduct.com/@loomduct/js@latest/dist/cdn/loomduct.js"
  data-token="lmt_your_project_token"
></script>

The first script creates window.loomduct right away, so you can call loomduct.track() anywhere on the page, even before the SDK has loaded. The second script loads the latest version of the SDK from the Loomduct CDN.

Publish your site

The script tracks page views on its own, also in single-page apps. To turn on more features, add data- attributes to the second script tag.

Check that it worked

  1. Open your website in a new tab. Loomduct skips localhost, so use the live site.
  2. Open your project in the dashboard. Your visit shows up as online now on the Overview within a few seconds.

If nothing shows up, open the browser's network tab on your site and look for a request to /l/e. A 202 answer means Loomduct received the event.