Installation guides
Replit
Add ProductLense to an app built with Replit Agent or by hand on Replit, then add the deployment domain to the site's hostnames.
On Replit you can ask Replit Agent to add the script, or add it yourself. Where it goes depends on the stack the app uses: the head of index.html for a Vite or static app, the root layout for Next.js, or the base template for Flask and Express apps that render HTML.
Replace SITE_ID with the id from Settings → Sites in the ProductLense dashboard.
The prompt
Add ProductLense analytics to every page of this app. Add these two tags, exactly as written, inside <head> of the HTML that every page uses (index.html, the root layout, or the base template). Do not install any package and do not import the script from JavaScript.
<script>window.productlense=window.productlense||function(){(window.productlense.q=window.productlense.q||[]).push(arguments)}</script>
<script defer data-site="SITE_ID" src="https://api.productlense.app/a.js"></script>
When a user signs in, call window.productlense('identify', userId) once in the browser with the signed-in user's id.Adding it yourself
index.html
<head>
<script>window.productlense=window.productlense||function(){(window.productlense.q=window.productlense.q||[]).push(arguments)}</script>
<script defer data-site="SITE_ID" src="https://api.productlense.app/a.js"></script>
</head>templates/base.html
<head>
<script>window.productlense=window.productlense||function(){(window.productlense.q=window.productlense.q||[]).push(arguments)}</script>
<script defer data-site="{{ config.PL_SITE_ID }}" src="https://api.productlense.app/a.js"></script>
</head>For other stacks, follow the matching guide: Next.js, Express, Flask and FastAPI, Django.
Domains
Replit serves the workspace preview and each deployment on different domains. Add the deployment's .replit.app domain, and your custom domain if you have one, to the site's hostnames in the ProductLense dashboard. Visits from a domain that is not listed are rejected.
Verify your installation
- Deploy, then open the deployment URL in a normal browser window.
- Open the Live page in the ProductLense dashboard. Your visit appears within a few seconds.
- In the browser's developer tools, the Network tab shows a
POSTtohttps://api.productlense.app/api/ewith status204.
If the visit does not appear, follow Verify your installation.