Skip to content

Install the widget with one script tag

One script tag for staging, a silent loader for the live site.

About 3 minutes · 5 steps · Get started

  1. Open Website widget

    Pick your website in the sidebar, then Website widget. The code on that screen has your project ID filled in.

  2. Staging and preview sites: paste the script

    Paste it before the closing body tag, or into a tag manager such as Zaraz (Custom HTML, all pageviews). The Feedback button is always visible, so use this on sites only your team and clients see.

    Staging and previews
    <script
      src="https://app.margin-comments.com/widget.js"
      data-project="YOUR_PROJECT_ID"
      data-environment="staging"
      data-build="your-build-id"
      defer
    ></script>
  3. Live site: paste the reviewer-only loader instead

    Visitors get nothing: no request and no button. The loader only fetches the widget in a browser that is in review mode.

    Live site, reviewers only
    <script>
    (function (d) {
      var q = location.search + location.hash;
      if (!/(^|; )margin_review=1/.test(d.cookie) &&
          !/[?&#](margin|margin_comment|margin_pair)=/.test(q)) return;
      var s = d.createElement("script");
      s.src = "https://app.margin-comments.com/widget.js";
      s.async = true;
      s.dataset.project = "YOUR_PROJECT_ID";
      s.dataset.environment = "production";
      s.dataset.mode = "review";
      d.head.appendChild(s);
    })(document);
    </script>
  4. Enter review mode

    Open the website from the dashboard once with Open website. The page opens already connected, and the browser stays in review mode for 30 days. Exit review mode in the widget ends it.

  5. Check that it works

    Reload the page. The Margin button appears. If it does not, the widget guide for missing buttons lists the usual causes.

Good to know

  • Set data-environment to staging, production or preview, and data-build to your build or commit ID. Both show up on every comment.
  • Never put an MCP token or a Cloudflare credential into your website. The widget needs only the project ID.

Next

Back to the Help Center. No account yet?