Install the tracking snippet with an NPM package
Overview
This method adds Reo.dev's tracking script as a code package inside your project, using npm or yarn (the tools JavaScript developers use to install and manage packages).
Use this if your website, documentation site, or product is built with a JavaScript framework, like React, Next.js, or Vue, and you or your engineering team manages that code directly.
Reo.dev tracks three types of assets:
Website
Documentation
Cloud Product (your logged-in product)
Each is configured separately in Reo.dev under Settings → Integrations. The install code below is the same for all three, with one small difference for Cloud Product noted in Step 2.
Is this the right method for you?
This method means editing your project's source code and redeploying it.
If that's not something you do yourself, share this page with whoever manages your site's or product's codebase.
Or, use one of the other install methods instead, pasting the script directly, or Google Tag Manager, neither of which touches your codebase.
Step 1: Install the package
In your project's terminal, run:
npm i reodotdev
# or
yarn add reodotdevThis adds Reo's tracking package to your project.
Step 2: Add the initialization code
Integrate the package into your project: Identify the file or module in your project where you want to add tracking, typically the root file that loads your entire application, for example
_app.js,layout.tsx, or a similar entry point.Import and load the tracking script: Import the required function from the package you installed, then use it to load Reo.dev's tracking script.
Add the code below to that file:
This code looks for a
CLIENT_IDenvironment variable first, and falls back to the literal string"XXXXXXXXXX"if none is set.Replace
"XXXXXXXXXX"directly with your Client ID.Set
CLIENT_IDas an environment variable in your project, using that same Client ID as its value.On a side note - adjust environment variables if needed: If you're using environment variables, make sure to set them up in your environment configuration or
.envfiles.
If you are setting up Cloud Product tracking instead, read this:
The code above includes a
.catch()block - the part starting with.catch(error => {...}).It only runs if the script fails to load, and its job is to print a message so you'd notice.
We'd recommend keeping it in your code: without it, a failed load happens silently, with no error and no message telling you it didn't work.
Step 3: Save, build, and deploy
Save the file containing the updated code.
Compile or bundle your project according to your build process, then deploy the changes to your server or hosting service.
The tracking script activates once your updated site or product is live.
Verify it worked
The fastest way: on the relevant configuration page (Documentation, Website or Cloud Product) in Reo.dev (Settings → Integrations), click Check status in the top-right corner. It tells you whether Reo.dev is receiving data.
To check manually instead:
Open your site
For Cloud Product tracking, log in first, since that's where the tracked screens live
Right-click anywhere on the page and select Inspect
In the Network tab, search for
reoand check if the network calls are being registered (status code: 200)
Advanced: identify logged-in users
If your product has a login, calling identify is an essential step.
Sign-in flows vary, some are built in-house, some use a third-party provider, some use an IDP (identity provider), so Reo.dev has no way to automatically detect a successful sign-in.
That's why it exposes
identifyas a method you call yourself, right after a successful sign-in, with the person's details as its payload.This tells Reo.dev who the user is and that they've logged in, attaching their activity to a real identity instead of leaving it anonymous.
identifyonly works after Reo.dev has finished loading, so call it afterReo.init(from Step 2), not before. TheReo &&check below confirms Reo.dev has finished loading beforeidentifyruns, so this doesn't error out if your sign-in callback fires too early.
The Reo && check simply confirms Reo.dev has finished loading before calling identify, so this doesn't error out if it runs too early.
usernameandtypeare required: the person's identifier, and what kind of identifier it is (email,github, orlinkedin).typedescribes the format of the username itself, not how the person signed in. For example, someone can sign in with GitHub but still be identified by their email address, in which caseusernamewould be their email andtypewould be"email".other_identitiesis optional: any other identifiers for the same person, for example their email if they signed in with GitHubfirstname,lastname, andcompanyare optional, and enrich their profile with extra detail
Advanced: copy tracking, and how to turn it off
By default, Reo.dev also tracks when someone copies a command or code snippet from your page.
This is a useful signal: someone copying your install command is likely about to try your product.
For logged-in users on your Cloud Product, like free or trial users, this also flags high-intent activity: copying a code block or running a CLI command is a strong proxy for how far along they are in evaluating your product.
If you'd rather turn copy tracking off entirely, add the dnt (do not track) flag when you initialize Reo.dev:
Error scenarios
1. The script doesn't load
The tracking snippet only runs after it downloads successfully from Reo.dev's Content Delivery Network (CDN), the servers that host the script file. A failed download doesn't break your page. It just means that visit isn't tracked.
This also won't throw visible errors in your browser's console. That's intentional: the script has built-in error handling so a tracking hiccup never clutters your production logs. If your site enforces a Content Security Policy, an unlisted domain can also cause this same silent failure, see CSP requirements below.
2. A tracking event occasionally fails to send
In rare cases, Reo.dev resets its internal authentication behind the scenes. If that happens while an event is sending, that one event may not go through, but this resolves on its own and later events send normally. No action is needed.
3. Avoid duplicate installs
Don't initialize Reo.dev more than once in the same project. Multiple copies can conflict with each other.
CSP requirements
If your site enforces a Content Security Policy (CSP), allow these domains. This is usually set in your site's HTTP response headers or a CSP meta tag, ask whoever manages your hosting if you're not sure where.
script-src <https://static.reo.dev>connect-src <https://api.reo.dev>
For cookies and data handling, see the cookie management guide.
FAQs
Do I need to set the
CLIENT_IDenvironment variable, or can I hardcode it? Either works. The environment variable in Step 2 is just a convention, so you're not hardcoding config values into your source code, but the Client ID itself isn't sensitive, so pasting it directly as a string works fine too.Should I add a
.catch()block for Cloud Product tracking? Yes, we recommend it. It only runs if the script fails to load, and its job is to print a message so you'd notice. See Step 2 for the full code and explanation.What happens if I don't call
identify()? Nothing breaks. Tracking still works, the session just stays anonymous instead of being linked to a known person.
Last updated
Was this helpful?

