Swetrix

Add tracking script to your website

To use Swetrix on your website, you need to add a tracking script to your website and there are several ways to do this.

Using a CMS or site builder?

If your website runs on WordPress, Wix, Shopify, Webflow, or another CMS/site builder, use a dedicated integration guide instead of editing HTML manually.

See CMS & website builder integrations.

The easiest way to add the tracking script to your website is to edit the HTML code of your website. To do this, paste the following code snippet into the Body section (<body> tag). You have to place the script within the <body>...</body> tags.

<script src="https://swetrix.org/swetrix.js" defer></script>
<script>
  document.addEventListener("DOMContentLoaded", function () {
    swetrix.init("YOUR_PROJECT_ID");
    swetrix.trackViews();
  });
</script>

<noscript>
  <img
    src="https://api.swetrix.com/log/noscript?pid=YOUR_PROJECT_ID"
    alt=""
    referrerpolicy="no-referrer-when-downgrade"
  />
</noscript>

It's important to remember to replace YOUR_PROJECT_ID with your actual Project ID, which you can find in the Dashboard, otherwise tracking will not work!

Done. Now you can start using Swetrix on your website.

To record session replays, start the recorder from your site code after initialising Swetrix. The replay recorder is loaded asynchronously only when you preload or start it. See startSessionReplay() for setup and privacy options.

On this page