AI app builders
Add Loogika to Replit
The Loogika tag goes into the HTML entry file of your Replit app, because the publishing settings of Replit offer no field for head code. Agent can add the tag for you, or you paste it into the file from the workspace. The tag reaches the live URL after you republish.
Last updated .
What do you need before you start?
Copy the script tag from the Tracking Script tab of Site Settings in the Loogika dashboard. The tag contains your site ID, a 12-character string, where the example says YOUR_SITE_ID:
<script src="https://app.loogika.com/api/script.js?siteId=YOUR_SITE_ID" defer></script>
How do you ask Replit Agent to add the Loogika tag?
Paste the prompt below into the Agent chat, with your own tag in it:
Add this script tag to the <head> of the app's HTML entry file so it loads on every page. Keep all existing head tags.
<script src="https://app.loogika.com/api/script.js?siteId=YOUR_SITE_ID" defer></script>
Look over what Agent proposes before you accept the change. A React component or a server file is the wrong place for the tag, which must sit in the HTML document.
Which file do you edit when you add the tag yourself?
The Files pane of the workspace lists the file that holds the head, and you open it from there. Which file that is depends on the kind of project.
| Project type | File to edit |
|---|---|
| Web app built by Agent, in most cases an Express server with a client made in Vite and React | client/index.html. In some projects the file is index.html at the top level |
| Next.js | app/layout.tsx. The Next.js guide has the code |
| Plain HTML with a Static deployment | Every page, or the shared template if you have one |
In an HTML entry file, paste the tag before the closing </head> tag:
<head>
<meta charset="UTF-8" />
<title>My app</title>
<script src="https://app.loogika.com/api/script.js?siteId=YOUR_SITE_ID" defer></script>
</head>
How do you publish the change?
Click Publish in the upper right for a first release, or Republish when the app is already live. Replit then sends out a new release at the same URL. Edits made in the Project Editor leave the live release untouched until then, so test in Preview first and republish afterwards.
Loogika tracks route changes inside the app as pageviews automatically. SPA Navigation in Site Settings controls that, and it is on for a new site.
How do you check that Loogika is installed?
Bring up the live URL in a separate browser tab and browse a few pages. The pageviews show up in the Loogika dashboard within a few seconds. If nothing arrives, open the page source and find script.js?siteId=, then see the script troubleshooting page.
What if Agent rewrites the file later?
A later request can make Agent generate client/index.html again, and the tag can be lost. When you request layout changes, add that Agent must leave the Loogika script in place. Check the page source again after a large refactor.
Why do the numbers differ from Replit's deployment analytics?
The two tools count different things. Replit's figure is the number of requests that reach the server. Loogika counts pageviews in the browser, so visitors with an ad blocker are missing, and bot detection removes automated traffic. The two numbers rarely match exactly.