Installation
Find your API key
Log in to PromptAlpha and navigate to Settings > Workspace. Your API key is displayed under the Tracking section. Copy it to your clipboard.
Add the snippet to your site
Paste the following code before the closing Replace
</head> tag on every page you want to track:YOUR_API_KEY with the API key you copied in the previous step.Deploy your changes
Publish or deploy your website with the snippet in place. The script loads asynchronously using the
defer attribute, so it will not block page rendering.How It Works
The PromptAlpha snippet is designed to be lightweight and privacy-respecting:- Small footprint — The script is under 5 KB gzipped and loads asynchronously via
defer, so it does not impact your page load performance. - Privacy-respecting — The snippet does not use cookies for tracking. It respects the browser’s Do Not Track (DNT) setting when enabled.
- AI source detection — The snippet identifies traffic from AI search engines by analyzing the
document.referrervalue. It recognizes referrers from ChatGPT, Perplexity, Claude, Gemini, Grok, and Google AI Overviews. - Crawler detection — AI crawler visits are detected server-side by matching known bot user-agent strings. The JavaScript snippet is not involved in crawler detection.
The snippet only collects data on the domains you have authorized in your workspace settings. See Allowed Domains below.
Platform-Specific Installation
WordPress
WordPress
You have two options for adding the snippet to a WordPress site:Option A: Edit your theme header
- Go to Appearance > Theme File Editor in your WordPress admin.
- Open the
header.phpfile. - Paste the snippet before the closing
</head>tag. - Click Update File.
- Install a plugin such as “Insert Headers and Footers” or “WPCode.”
- Navigate to the plugin’s settings page.
- Paste the snippet into the Header section.
- Save your changes.
Shopify
Shopify
- In your Shopify admin, go to Online Store > Themes.
- Click Actions > Edit code on your active theme.
- Open the
theme.liquidfile under Layout. - Paste the snippet before the closing
</head>tag. - Click Save.
Next.js
Next.js
Add the snippet to your root layout file so it loads on every page.App Router (Pages Router (
app/layout.tsx)pages/_document.tsx)Static HTML
Static HTML
Open your HTML file and paste the snippet directly inside the If your site has multiple HTML files, add the snippet to every page you want to track. If you use a templating system or server-side includes, add it to the shared header template.
<head> section:Allowed Domains
PromptAlpha only collects data from domains you have explicitly authorized. To configure your allowed domains:- Go to Settings > Workspace > Allowed Domains.
- Add each domain where you have installed the tracking snippet (e.g.,
example.com,www.example.com). - Click Save.
Subdomains are treated separately. If your site runs on both
example.com and www.example.com, add both. Requests from unauthorized domains are silently ignored.Troubleshooting
No data appearing after 24 hours
No data appearing after 24 hours
- Confirm the snippet is present in your page’s
<head>section by viewing the page source in your browser. - Verify that
YOUR_API_KEYhas been replaced with your actual API key from Settings > Workspace. - Check that your domain is listed under Allowed Domains in your workspace settings.
- Open your browser’s developer console (F12 > Console) and look for any errors related to
pa.js.
Snippet is present but pa.js fails to load
Snippet is present but pa.js fails to load
- Check that your Content Security Policy (CSP) allows scripts from
app.promptalpha.ai. You may need to addhttps://app.promptalpha.aito yourscript-srcdirective. - Confirm that no ad blocker or browser extension is blocking the request.
- Verify network connectivity to
https://app.promptalpha.ai/pa.jsby opening the URL directly in your browser.
AI traffic data is missing but crawler data shows
AI traffic data is missing but crawler data shows
AI traffic detection depends on the JavaScript snippet running in the user’s browser. If crawler data appears but AI-referred traffic does not:
- Confirm the snippet is loading on the correct pages.
- Check that the referrer is not being stripped by a
Referrer-Policyheader set tono-referrer. Useno-referrer-when-downgradeorstrict-origin-when-cross-origininstead. - Allow up to 48 hours for traffic data to fully populate after initial installation.
Duplicate page views or inflated numbers
Duplicate page views or inflated numbers
- Ensure the snippet is only included once per page. Check for duplicate inclusions in both your HTML template and any tag managers.
- If you use a single-page application (SPA) framework, the snippet handles route changes automatically. You do not need to re-initialize it on navigation.

