OnyxMetric
Integration Guides

Replit

Add OnyxMetric analytics to your Replit app

Replit has no publishing setting for custom head code, so the tag goes into the app's HTML entry file. Ask Agent to add it, or open the file in the workspace and paste it yourself. The change reaches the live URL only after you republish.

Copy your tracking snippet

In OnyxMetric, open your site's Site Settings and copy the tracking script. It looks like this:

<script src="https://app.onyxmetric.com/api/script.js?siteId=YOUR_SITE_ID" async></script>

YOUR_SITE_ID is the numeric ID of your site.

Add the snippet to Replit

Paste this into the chat:

Add this script tag to the <head> of every page and keep all existing head tags:
<script src="https://app.onyxmetric.com/api/script.js?siteId=YOUR_SITE_ID" async></script>

Review the change: the tag belongs in the document head, not inside a component.

Open the file that owns the <head> from the Files pane:

  • Agent-built web apps are usually a Vite + React client with an Express server, and the HTML entry is client/index.html. Some projects keep it at index.html in the root.
  • Next.js projects use app/layout.tsx with next/script, as in the Next.js guide.
  • Plain HTML projects (Static deployments): add the tag to every page, or to a shared template.

Paste the snippet before </head>:

client/index.html
<head>
  <meta charset="UTF-8" />
  <title>My app</title>
  <script src="https://app.onyxmetric.com/api/script.js?siteId=YOUR_SITE_ID" async></script>
</head>

Then click Publish at the upper right (or Republish for a live app) so a new release goes out at the same URL. In-app route changes are tracked as pageviews automatically.

Check that it works

Load your live site and click through a few pages. Pageviews show up in the OnyxMetric dashboard within seconds.

If nothing arrives:

  • View the page source and search for script.js?siteId= to confirm the tag is present.
  • In the browser's Network tab, check that script.js returns 200 and that requests go to /api/track.
  • Turn off ad blockers, or proxy the script through your own domain.
  • Read script troubleshooting for other causes.

Troubleshooting

  • Live app has no script: workspace edits do not replace the live release. Test in Preview, then click Republish.
  • Agent rewrote the file: a later request can regenerate client/index.html. Tell Agent to keep the OnyxMetric script, and re-check the page source after large refactors.
  • Numbers differ from Replit's deployment analytics: Replit counts server requests. OnyxMetric counts browser pageviews after bot filtering, so the two rarely match.

Next steps

On this page