About this project
Promptwatch Analytics provides a simple way to add Promptwatch’s AI search visibility tracking to any web application. The package exports a loadPromptwatch function that creates a script element, sets the required data-project-id attribute, and appends it to the document head. By loading the remote client.min.js script, sites can collect data on how AI assistants reference their content.
Installation is straightforward with any JavaScript package manager: npm install @promptwatch/analytics, yarn add @promptwatch/analytics, or pnpm add @promptwatch/analytics.
Usage examples:
- In plain JavaScript or any framework, import loadPromptwatch and call it with your project identifier.
- For React, the package includes a PromptwatchScript component that can be placed in the component tree, including Next.js App Router client components or layout files.
- In Angular, call loadPromptwatch inside the AfterViewInit lifecycle hook of a component.
The loader accepts an optional options object where the script URL can be overridden, allowing flexibility for custom hosting or versioning.
All code is released under the MIT license, making it free to use and modify in commercial or open‑source projects.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.