<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Privatus Analytics</title>
    <description>The latest articles on DEV Community by Privatus Analytics (@privatusanalytics).</description>
    <link>https://dev.to/privatusanalytics</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4207531%2F78151dce-ac99-487f-9981-5f62ec4043e5.png</url>
      <title>DEV Community: Privatus Analytics</title>
      <link>https://dev.to/privatusanalytics</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/privatusanalytics"/>
    <language>en</language>
    <item>
      <title>Ask Claude or ChatGPT About Your Website Traffic with an MCP Server</title>
      <dc:creator>Privatus Analytics</dc:creator>
      <pubDate>Mon, 26 Oct 2026 02:23:33 +0000</pubDate>
      <link>https://dev.to/privatusanalytics/ask-claude-or-chatgpt-about-your-website-traffic-with-an-mcp-server-380g</link>
      <guid>https://dev.to/privatusanalytics/ask-claude-or-chatgpt-about-your-website-traffic-with-an-mcp-server-380g</guid>
      <description>&lt;p&gt;You want to know a simple thing. Which blog post brought the most visitors last month?&lt;/p&gt;

&lt;p&gt;So you open your analytics dashboard. You pick a date range. You open three menus. You export a table. Then you copy it into a chat with an AI to ask what it means. Next week you do it all again.&lt;/p&gt;

&lt;p&gt;There is a better way. You can let the AI look at your numbers itself. You just type a question, like you would ask a coworker.&lt;/p&gt;

&lt;p&gt;This works through something called MCP. In this tutorial you will connect Claude or ChatGPT to your analytics, step by step. You will also learn how to keep it safe, so the AI can only read and cannot break anything.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is MCP?
&lt;/h2&gt;

&lt;p&gt;MCP stands for Model Context Protocol. It is a standard way for an AI app to talk to other tools. Think of a plug that fits many sockets. A tool that offers an MCP server says, "Here is a list of things you can ask me to do." The AI picks the right ones.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://privatusanalytics.com" rel="noopener noreferrer"&gt;Privatus Analytics&lt;/a&gt; runs a hosted MCP server. It is a cookieless web analytics tool. The free plan gives you 10,000 events a month and up to 3 sites, with no card. If you use another analytics tool, check whether it has an MCP server too.&lt;/p&gt;

&lt;p&gt;The server lives at this address:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://privatusanalytics.com/mcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It works with Claude, ChatGPT, Gemini CLI, Cursor and VS Code. This guide covers the most common ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Pick how to sign in
&lt;/h2&gt;

&lt;p&gt;You have two choices.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;OAuth.&lt;/strong&gt; You click "connect", sign in, and approve. No secret key to copy. This is the easiest. You choose the workspace, and you choose &lt;strong&gt;Read-only&lt;/strong&gt; or &lt;strong&gt;Full access&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;API token.&lt;/strong&gt; You make a key (it starts with &lt;code&gt;pat_&lt;/code&gt;) and put it in the config. This gives you the most control over exactly what the AI can touch.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For your first try, I suggest OAuth with &lt;strong&gt;Read-only&lt;/strong&gt;. The read-only choice gives the AI the &lt;code&gt;analytics.read&lt;/code&gt; permission and nothing more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2A: Connect Claude (desktop or web)
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Open &lt;strong&gt;Settings&lt;/strong&gt;, then &lt;strong&gt;Connectors&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Add custom connector&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Name it "Privatus Analytics". Enter &lt;code&gt;https://privatusanalytics.com/mcp&lt;/code&gt; as the address.&lt;/li&gt;
&lt;li&gt;A browser window opens. Sign in to Privatus Analytics, pick your workspace, choose &lt;strong&gt;Read-only&lt;/strong&gt;, and approve.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step 2B: Connect Claude Code
&lt;/h2&gt;

&lt;p&gt;If you use Claude Code in a terminal, run this with your own token:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;claude mcp add &lt;span class="nt"&gt;--transport&lt;/span&gt; http privatus https://privatusanalytics.com/mcp &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--header&lt;/span&gt; &lt;span class="s2"&gt;"Authorization: Bearer pat_YOUR_TOKEN"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add &lt;code&gt;--scope user&lt;/code&gt; to use it in every project. Add &lt;code&gt;--scope project&lt;/code&gt; to share it with your team through a &lt;code&gt;.mcp.json&lt;/code&gt; file. If you share it, use an environment variable for the token, so you never commit a secret.&lt;/p&gt;

&lt;p&gt;Prefer OAuth? Leave out &lt;code&gt;--header&lt;/code&gt;. Then run &lt;code&gt;/mcp&lt;/code&gt; inside Claude Code and sign in there.&lt;/p&gt;

&lt;p&gt;To make a token, go to &lt;strong&gt;Workspace settings&lt;/strong&gt;, then &lt;strong&gt;API tokens&lt;/strong&gt;. Pick only the &lt;code&gt;analytics.read&lt;/code&gt; permission. Pick the sites it may see, and set an expiry date. The &lt;a href="https://privatusanalytics.com/docs/api/authentication" rel="noopener noreferrer"&gt;authentication page&lt;/a&gt; explains each option.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2C: Connect ChatGPT
&lt;/h2&gt;

&lt;p&gt;ChatGPT uses "custom connectors" for MCP.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Turn on &lt;strong&gt;developer mode&lt;/strong&gt; in ChatGPT's settings.&lt;/li&gt;
&lt;li&gt;Create a new connector.&lt;/li&gt;
&lt;li&gt;Enter &lt;code&gt;https://privatusanalytics.com/mcp&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Choose &lt;strong&gt;OAuth&lt;/strong&gt; for sign-in.&lt;/li&gt;
&lt;li&gt;A window opens. Sign in to Privatus Analytics and approve.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Other tools have their own steps. Gemini CLI, Cursor and VS Code are covered on the &lt;a href="https://privatusanalytics.com/docs/mcp" rel="noopener noreferrer"&gt;MCP docs page&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Check that it works
&lt;/h2&gt;

&lt;p&gt;Before you ask the AI anything, you can test your token with &lt;code&gt;curl&lt;/code&gt;. This lists the tools the server will give you:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://privatusanalytics.com/mcp &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Authorization: Bearer &lt;/span&gt;&lt;span class="nv"&gt;$PRIVATUS_TOKEN&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Accept: application/json, text/event-stream"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'{"jsonrpc":"2.0","id":1,"method":"tools/list"}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With a read-only token the list is short. The server only shows tools that your token is allowed to use. That is a handy proof that the limits work.&lt;/p&gt;

&lt;p&gt;Now call one tool by hand:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://privatusanalytics.com/mcp &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Authorization: Bearer &lt;/span&gt;&lt;span class="nv"&gt;$PRIVATUS_TOKEN&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Accept: application/json, text/event-stream"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'{
    "jsonrpc": "2.0", "id": 2, "method": "tools/call",
    "params": {
      "name": "stats_aggregate",
      "arguments": { "site_id": "pa_YOURSITEID", "period": "7d", "compare": "previous_period" }
    }
  }'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You get back the same numbers the dashboard shows. If this works, the AI will work too.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Ask real questions
&lt;/h2&gt;

&lt;p&gt;Open a chat in Claude or ChatGPT, and try prompts like these. They come from the docs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"Which pages on example.com got the most visitors from AI assistants last month, and how did that change from the month before?"&lt;/li&gt;
&lt;li&gt;"Compare signup conversion rate by channel for the last 90 days."&lt;/li&gt;
&lt;li&gt;"Are any of my uptime checks down right now?"&lt;/li&gt;
&lt;li&gt;"How do I track outbound links with Privatus Analytics?"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Replace &lt;code&gt;example.com&lt;/code&gt; with your own site.&lt;/p&gt;

&lt;p&gt;Behind the scenes, the AI picks tools by name. Tools are named like &lt;code&gt;resource_verb&lt;/code&gt;. For the first prompt, it may call &lt;code&gt;stats_breakdown&lt;/code&gt; with the page as the dimension, last month as the period, and a filter for the AI assistants channel. A usual path is: &lt;code&gt;workspaces_list&lt;/code&gt; to find your workspace, &lt;code&gt;sites_list&lt;/code&gt; to find your site, and then a stats tool for the numbers. The last example uses &lt;code&gt;docs_search&lt;/code&gt;, which lets the AI read the docs.&lt;/p&gt;

&lt;p&gt;You do not need to know any of this to use it. It is just good to know what is going on.&lt;/p&gt;

&lt;h2&gt;
  
  
  Staying safe
&lt;/h2&gt;

&lt;p&gt;Giving an AI access to your tools is a big step. Here is how to keep it small and safe.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use the smallest key.&lt;/strong&gt; Give each AI its own token, with just the permissions and sites it needs, and an expiry date. If you only need reports, &lt;code&gt;analytics.read&lt;/code&gt; is enough.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Some actions are left to you.&lt;/strong&gt; An AI can pick the wrong tool or the wrong ID. So the hard-to-undo actions are not done by the AI. These include deleting data, billing, access settings and API tokens. The AI only gets a link to the right page in the app, and you do it yourself.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No secrets go through the chat.&lt;/strong&gt; No tool takes a password or an API key, because chats are saved in a transcript.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;You get an email for risky actions.&lt;/strong&gt; If an AI creates an export or changes a webhook with your token, you receive an email that names the action and the token.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check the list of tokens.&lt;/strong&gt; An OAuth connection makes a token named after the app, with "(MCP)" at the end. You can see it in your token list and revoke it any time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The full rules are on the &lt;a href="https://privatusanalytics.com/docs/mcp" rel="noopener noreferrer"&gt;MCP docs page&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  When the AI gets it wrong
&lt;/h2&gt;

&lt;p&gt;Language models can make mistakes. If a number looks odd, ask the AI which tool it called and with which settings. Then compare it with the dashboard. Stats come straight from the API, so the data is reliable, but the AI's reading of it may not be. Treat it like a quick helper and not a final judge.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you get
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Plain-English questions about your traffic, in the chat app you already use&lt;/li&gt;
&lt;li&gt;No more exporting tables and pasting them into prompts&lt;/li&gt;
&lt;li&gt;A read-only connection, with hard-to-undo actions left to you&lt;/li&gt;
&lt;li&gt;Numbers with bots filtered out and no tracking cookies behind them&lt;/li&gt;
&lt;li&gt;A setup for Claude, Claude Code, ChatGPT, Gemini CLI, Cursor and VS Code&lt;/li&gt;
&lt;li&gt;A free plan with 10,000 events a month and up to 3 sites, no card needed&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;Start with a free account at &lt;a href="https://privatusanalytics.com" rel="noopener noreferrer"&gt;privatusanalytics.com&lt;/a&gt;, add the script to your site, and wait for some visits. Then connect your AI of choice with the steps above. The &lt;a href="https://privatusanalytics.com/pricing" rel="noopener noreferrer"&gt;pricing page&lt;/a&gt; shows what the paid plans add. The open-source parts of the project live in the &lt;a href="https://github.com/Privatus-Analytics" rel="noopener noreferrer"&gt;Privatus Analytics GitHub organization&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>mcp</category>
      <category>ai</category>
      <category>analytics</category>
      <category>privacy</category>
    </item>
    <item>
      <title>Send Your Website Stats to Slack Every Morning with n8n</title>
      <dc:creator>Privatus Analytics</dc:creator>
      <pubDate>Mon, 26 Oct 2026 02:17:23 +0000</pubDate>
      <link>https://dev.to/privatusanalytics/send-your-website-stats-to-slack-every-morning-with-n8n-1af9</link>
      <guid>https://dev.to/privatusanalytics/send-your-website-stats-to-slack-every-morning-with-n8n-1af9</guid>
      <description>&lt;p&gt;Here is a small daily habit. You open your analytics tool. You log in. You wait for it to load. You click around to find one number. Then you forget to do it for a week.&lt;/p&gt;

&lt;p&gt;Or maybe the tool is so slow and confusing that you stop looking at all. Many people feel this way about Google Analytics.&lt;/p&gt;

&lt;p&gt;Let us fix that. In this tutorial you will make a workflow that posts a short message in Slack every morning. It will say how many people visited your site yesterday, and how that compares with the day before. You do not have to log in to anything.&lt;/p&gt;

&lt;p&gt;You will use three things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://n8n.io" rel="noopener noreferrer"&gt;n8n&lt;/a&gt;, a tool that connects apps and runs steps on a schedule. You can host it yourself or use their cloud.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://privatusanalytics.com" rel="noopener noreferrer"&gt;Privatus Analytics&lt;/a&gt;, a cookieless web analytics tool. The free plan gives you 10,000 events a month and up to 3 sites. No card is needed.&lt;/li&gt;
&lt;li&gt;Slack, where the message will land.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you already use Zapier or Make, the idea is the same. There are Privatus Analytics apps for those too. This guide uses n8n.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Install the community node
&lt;/h2&gt;

&lt;p&gt;A "community node" is an add-on made by someone outside the n8n team. The package is called &lt;code&gt;n8n-nodes-privatus-analytics&lt;/code&gt; and you can find it on &lt;a href="https://www.npmjs.com/package/n8n-nodes-privatus-analytics" rel="noopener noreferrer"&gt;npm&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In n8n:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open &lt;strong&gt;Settings&lt;/strong&gt;, then &lt;strong&gt;Community Nodes&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Install&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Type &lt;code&gt;n8n-nodes-privatus-analytics&lt;/code&gt; and confirm.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you host n8n yourself, you can also run this in your n8n folder (&lt;code&gt;~/.n8n/nodes&lt;/code&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;n8n-nodes-privatus-analytics
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Restart n8n, and the new nodes show up in the node list.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Make an API token
&lt;/h2&gt;

&lt;p&gt;The node needs permission to read your numbers. That permission is called an API token. Think of it like a key card for software.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In Privatus Analytics, open &lt;strong&gt;Workspace settings&lt;/strong&gt;, then &lt;strong&gt;API tokens&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Create a token and give it a name like "n8n".&lt;/li&gt;
&lt;li&gt;Copy it. It starts with &lt;code&gt;pat_&lt;/code&gt;. You only see it once, so paste it somewhere safe right away.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The node's README suggests keeping all permissions, choosing every site, and setting no expiry, so that every operation works. This workflow only reads numbers. So you can try a token with only the &lt;code&gt;analytics.read&lt;/code&gt; permission, and see if the credential test in the next step passes. A smaller key is safer. Tokens are explained on the &lt;a href="https://privatusanalytics.com/docs/api/authentication" rel="noopener noreferrer"&gt;authentication page&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Add the credential in n8n
&lt;/h2&gt;

&lt;p&gt;In n8n, create a new credential called &lt;strong&gt;Privatus Analytics API&lt;/strong&gt; and paste your token. n8n tests it when you save. A green check means it works.&lt;/p&gt;

&lt;p&gt;A token belongs to one workspace. If you have two workspaces, make two credentials.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Build the workflow
&lt;/h2&gt;

&lt;p&gt;You need three nodes in a row.&lt;/p&gt;

&lt;h3&gt;
  
  
  Node 1: Schedule Trigger
&lt;/h3&gt;

&lt;p&gt;Add a &lt;strong&gt;Schedule Trigger&lt;/strong&gt;. Set it to run every day at 8:00. Check the timezone setting in your n8n so "8:00" means your morning.&lt;/p&gt;

&lt;h3&gt;
  
  
  Node 2: Privatus Analytics
&lt;/h3&gt;

&lt;p&gt;Add the &lt;strong&gt;Privatus Analytics&lt;/strong&gt; node and set:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Resource:&lt;/strong&gt; Stats&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Operation:&lt;/strong&gt; Get Overview&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Site:&lt;/strong&gt; pick your site from the list&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Period:&lt;/strong&gt; Yesterday (if it is not in the list, pick a custom range of one day)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Additional Fields, Compare With:&lt;/strong&gt; Previous Period&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The list of sites loads from your workspace, so there is nothing to type.&lt;/p&gt;

&lt;p&gt;After you run this node, look at its output. You will see a &lt;code&gt;metrics&lt;/code&gt; part with numbers like &lt;code&gt;visitors&lt;/code&gt;, &lt;code&gt;pageviews&lt;/code&gt;, &lt;code&gt;bounce_rate&lt;/code&gt; and more. The &lt;code&gt;change&lt;/code&gt; part shows the percent change since the comparison period. If there was nothing to compare to, a change can be &lt;code&gt;null&lt;/code&gt;, which means "no value".&lt;/p&gt;

&lt;h3&gt;
  
  
  Node 3: Slack
&lt;/h3&gt;

&lt;p&gt;Add the &lt;strong&gt;Slack&lt;/strong&gt; node. Connect your Slack account the way n8n shows you. Then set it to send a message to a channel, for example &lt;code&gt;#general&lt;/code&gt; or a private &lt;code&gt;#stats&lt;/code&gt; channel.&lt;/p&gt;

&lt;p&gt;For the message text, use an expression. An expression is a bit of code inside &lt;code&gt;{{ }}&lt;/code&gt; that n8n swaps for real data:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Good morning! Yesterday your site had {{ $json.metrics.visitors }} visitors and {{ $json.metrics.pageviews }} page views.
Visitors changed by {{ $json.change.visitors ?? 'n/a' }}% compared with the day before.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;?? 'n/a'&lt;/code&gt; part says "if there is no value, write n/a". It keeps the message clean on the first day, when there is nothing to compare.&lt;/p&gt;

&lt;p&gt;Click &lt;strong&gt;Execute workflow&lt;/strong&gt; once. Check Slack. You should see your message right away.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Switch it on
&lt;/h2&gt;

&lt;p&gt;Click the &lt;strong&gt;Active&lt;/strong&gt; toggle at the top of the workflow. From now on it runs on its own each morning.&lt;/p&gt;

&lt;h2&gt;
  
  
  No community node? Use the REST API
&lt;/h2&gt;

&lt;p&gt;Maybe your n8n does not allow community nodes. Or you like to keep things basic. The same data is available over plain HTTP. Replace Node 2 with an &lt;strong&gt;HTTP Request&lt;/strong&gt; node:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Method:&lt;/strong&gt; GET&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;URL:&lt;/strong&gt; &lt;code&gt;https://privatusanalytics.com/sites/pa_YOURSITEID/stats/aggregate.json&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Query parameters:&lt;/strong&gt; &lt;code&gt;period&lt;/code&gt; = &lt;code&gt;yesterday&lt;/code&gt;, and &lt;code&gt;compare&lt;/code&gt; = &lt;code&gt;previous_period&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Header:&lt;/strong&gt; &lt;code&gt;Authorization&lt;/code&gt; = &lt;code&gt;Bearer pat_YOUR_TOKEN&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can test it first in a terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="s2"&gt;"https://privatusanalytics.com/sites/pa_YOURSITEID/stats/aggregate.json?period=yesterday&amp;amp;compare=previous_period"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Authorization: Bearer &lt;/span&gt;&lt;span class="nv"&gt;$PRIVATUS_TOKEN&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The reply looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"data"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"metrics"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"visitors"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;8120&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"pageviews"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;24871&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"change"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"visitors"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;9.6&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(The real reply has more fields. This is a short version.) The numbers are inside &lt;code&gt;data&lt;/code&gt;, so in Slack you would write &lt;code&gt;{{ $json.data.metrics.visitors }}&lt;/code&gt; instead. The &lt;a href="https://privatusanalytics.com/docs/api/stats" rel="noopener noreferrer"&gt;stats API page&lt;/a&gt; lists every field and what it means. For example, &lt;code&gt;bounce_rate&lt;/code&gt; is a percent and &lt;code&gt;visit_duration&lt;/code&gt; is in milliseconds.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ideas to make it better
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A weekly report.&lt;/strong&gt; Change the period to &lt;code&gt;7d&lt;/code&gt; and the schedule to Monday at 8:00.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Top pages.&lt;/strong&gt; Add a second Privatus Analytics node with the &lt;strong&gt;Get Top Values&lt;/strong&gt; operation, to list your best pages. Merge it into the same Slack message.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Alerts when something breaks.&lt;/strong&gt; The package also has a &lt;strong&gt;Trigger&lt;/strong&gt; node. It starts a workflow when an event happens, such as an uptime check going down. Send those to a different channel, so a real emergency does not get lost in a daily message.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Thank happy customers.&lt;/strong&gt; Trigger on a new 5-star testimonial and send a thank-you email.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The trigger checks a signature on every delivery, so a fake request from a stranger is rejected. Details are in the &lt;a href="https://github.com/Privatus-Analytics/n8n-nodes-privatus-analytics" rel="noopener noreferrer"&gt;package README on GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you get
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A Slack message with yesterday's numbers every morning, with no login&lt;/li&gt;
&lt;li&gt;A comparison with the day before, so you can see the trend at a glance&lt;/li&gt;
&lt;li&gt;Numbers with bots filtered out, so they reflect real people&lt;/li&gt;
&lt;li&gt;A workflow you can change into weekly reports, alerts and more&lt;/li&gt;
&lt;li&gt;Data that stays between your own tools, not sent to Google&lt;/li&gt;
&lt;li&gt;A free plan with 10,000 events a month and up to 3 sites, no card needed&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;If you do not have a Privatus Analytics account yet, the free plan is at &lt;a href="https://privatusanalytics.com" rel="noopener noreferrer"&gt;privatusanalytics.com&lt;/a&gt;. See the &lt;a href="https://privatusanalytics.com/pricing" rel="noopener noreferrer"&gt;pricing page&lt;/a&gt; for the paid plans. Set up the script on your site first, wait a day, and then build this workflow. Your first Slack message will be ready the next morning.&lt;/p&gt;

</description>
      <category>n8n</category>
      <category>automation</category>
      <category>slack</category>
      <category>analytics</category>
    </item>
    <item>
      <title>Replace Google Analytics in WordPress Without a Cookie Pop-Up</title>
      <dc:creator>Privatus Analytics</dc:creator>
      <pubDate>Mon, 26 Oct 2026 02:11:09 +0000</pubDate>
      <link>https://dev.to/privatusanalytics/replace-google-analytics-in-wordpress-without-a-cookie-pop-up-3o6m</link>
      <guid>https://dev.to/privatusanalytics/replace-google-analytics-in-wordpress-without-a-cookie-pop-up-3o6m</guid>
      <description>&lt;p&gt;Open Google Analytics for your WordPress site. How long does it take to find "how many people read my last post"?&lt;/p&gt;

&lt;p&gt;For many people, it takes too long. The menus change. The words are strange. And before any of this works, your site needs a cookie pop-up. Visitors who click "no" are not counted at all. So the numbers you do see are lower than the truth. Every visit that is counted is also sent to Google.&lt;/p&gt;

&lt;p&gt;In this guide you will replace all of that with a plugin. It takes a few minutes. You will end up with a simple dashboard, no tracking cookies, and no cookie pop-up for your analytics.&lt;/p&gt;

&lt;p&gt;We will use &lt;a href="https://privatusanalytics.com" rel="noopener noreferrer"&gt;Privatus Analytics&lt;/a&gt;. Other privacy-friendly tools exist too, like Plausible, Fathom and Matomo. Look at a few if you like. The steps below are for Privatus Analytics.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you need
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A WordPress site where you can install plugins. WordPress 6.4 or newer, and PHP 7.4 or newer.&lt;/li&gt;
&lt;li&gt;A free Privatus Analytics account. You get 10,000 events a month and up to 3 sites. No card is needed. An "event" is one thing that gets counted, like a page view.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 1: Add your site and copy the site ID
&lt;/h2&gt;

&lt;p&gt;Sign in to Privatus Analytics and add your site. You will get a site ID that starts with &lt;code&gt;pa_&lt;/code&gt;. Copy it. It is not a password. The &lt;a href="https://privatusanalytics.com/docs/getting-started/add-a-site" rel="noopener noreferrer"&gt;Add a site guide&lt;/a&gt; shows the clicks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Install the plugin
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;In your WordPress admin, go to &lt;strong&gt;Plugins&lt;/strong&gt;, then &lt;strong&gt;Add New&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Search for &lt;strong&gt;Privatus Analytics&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Check the author name. It should be &lt;strong&gt;privatusanalytics&lt;/strong&gt;. Anyone can upload a plugin with a similar name, so it is smart to check.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Install Now&lt;/strong&gt;, then &lt;strong&gt;Activate&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can also open the plugin page directly at &lt;a href="https://wordpress.org/plugins/privatus-analytics/" rel="noopener noreferrer"&gt;wordpress.org/plugins/privatus-analytics&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you would rather not use a plugin, there is a way to paste the script into your theme. The &lt;a href="https://privatusanalytics.com/docs/install/wordpress" rel="noopener noreferrer"&gt;WordPress install guide&lt;/a&gt; shows that way too. The plugin is easier, and it adds a few extras that I cover below.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Paste your site ID
&lt;/h2&gt;

&lt;p&gt;Go to &lt;strong&gt;Settings&lt;/strong&gt;, then &lt;strong&gt;Privatus Analytics&lt;/strong&gt;. Paste your site ID into the &lt;strong&gt;Site ID&lt;/strong&gt; box. Click save.&lt;/p&gt;

&lt;p&gt;That is all you must do. The plugin now adds a small script to the top of every page that visitors see. It does not add it to the admin area, to previews, or to feeds.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Keep your own visits out
&lt;/h2&gt;

&lt;p&gt;You do not want to count yourself. The plugin has a setting called &lt;strong&gt;Do not track roles&lt;/strong&gt;. People who are logged in with a chosen role are not counted. &lt;strong&gt;Administrator&lt;/strong&gt; is picked by default. So when you check your own site while logged in, nothing is counted.&lt;/p&gt;

&lt;p&gt;Want to leave out editors too? Tick their role as well.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Check that it works
&lt;/h2&gt;

&lt;p&gt;Open your site in a private window, so you are not logged in. Click through two or three pages. Then look at your dashboard. You should see the visits.&lt;/p&gt;

&lt;p&gt;If you see nothing, a caching plugin is the usual cause. Plugins such as WP Rocket, Autoptimize and LiteSpeed Cache can combine or delay scripts. Tell them to leave &lt;code&gt;pa.js&lt;/code&gt; alone. Look in the "combine", "defer JavaScript" and "delay JavaScript" settings. Clear your cache after that. The &lt;a href="https://privatusanalytics.com/docs/troubleshooting/caching" rel="noopener noreferrer"&gt;caching troubleshooting guide&lt;/a&gt; has more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6: Remove Google Analytics
&lt;/h2&gt;

&lt;p&gt;Now that the new tool counts visits, turn off the old one. Where it lives depends on how you added it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you used a plugin like Site Kit, deactivate it.&lt;/li&gt;
&lt;li&gt;If you pasted a snippet into your theme or a "header and footer" plugin, delete that snippet.&lt;/li&gt;
&lt;li&gt;If you used Google Tag Manager for it, remove the Google Analytics tag there.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Keep your old Google data if you want it. It does not go away when you stop sending new data. Privatus Analytics can also import Google Analytics history. See the &lt;a href="https://privatusanalytics.com/docs" rel="noopener noreferrer"&gt;docs&lt;/a&gt; for that.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 7: Remove the cookie pop-up (if it was only for analytics)
&lt;/h2&gt;

&lt;p&gt;The Privatus Analytics script does not set tracking cookies. So it does not need a pop-up of its own.&lt;/p&gt;

&lt;p&gt;Be careful here. Other things on your site may still use cookies, like ads, chat boxes or embedded videos. If they do, you may still need a pop-up for them. Rules are also different in every country. So only remove the pop-up when analytics was the only reason for it, and check the rules where your visitors live.&lt;/p&gt;

&lt;p&gt;Many people see a nice side effect. Without a pop-up, the page loads cleaner and nobody gets blocked from your content.&lt;/p&gt;

&lt;h2&gt;
  
  
  Optional: track WooCommerce sales
&lt;/h2&gt;

&lt;p&gt;Do you run a shop with WooCommerce? Open the plugin settings and switch on &lt;strong&gt;WooCommerce: track purchases&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;On the "thank you" page after an order, the plugin sends one &lt;code&gt;purchase&lt;/code&gt; event. It includes the order total, the currency, the number of items, and whether a coupon was used.&lt;/p&gt;

&lt;p&gt;It does not send the order number, the name, the email, or the address. The plugin also hides order numbers in page addresses, so they never show up in your reports.&lt;/p&gt;

&lt;h2&gt;
  
  
  Optional: let visitors opt out
&lt;/h2&gt;

&lt;p&gt;Add this shortcode to any page, such as your privacy page:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[privatus_optout]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It shows a button. A visitor can click it to stop being counted. It saves one small flag in the browser to remember the choice. The plugin also adds suggested text for your privacy policy. You will find it under &lt;strong&gt;Settings&lt;/strong&gt;, then &lt;strong&gt;Privacy&lt;/strong&gt;, in the policy guide.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the numbers may look different
&lt;/h2&gt;

&lt;p&gt;Do not panic if your new numbers are not the same as Google's. Three things are normal:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Cookie pop-up visitors are back.&lt;/strong&gt; The people who said "no" to the old pop-up are now counted.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bots are filtered out.&lt;/strong&gt; Privatus Analytics checks every visit against rules for known crawlers, test tools, and servers in data centers. Those visits are left out and do not use up your event limit. The &lt;a href="https://privatusanalytics.com/docs/features/bot-filtering" rel="noopener noreferrer"&gt;bot filtering page&lt;/a&gt; has the full list of rules.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ad blockers.&lt;/strong&gt; Some blockers stop any analytics script. No tool can fully fix that.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So your total might go up or down. Either way, it is closer to what real people did.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you get
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Analytics set up through the plugin, with no code&lt;/li&gt;
&lt;li&gt;No tracking cookies, so no cookie pop-up for this tool&lt;/li&gt;
&lt;li&gt;Your own admin visits left out&lt;/li&gt;
&lt;li&gt;Bots filtered out of the reports&lt;/li&gt;
&lt;li&gt;Optional WooCommerce sales tracking without personal details&lt;/li&gt;
&lt;li&gt;An opt-out button for visitors who want it&lt;/li&gt;
&lt;li&gt;A free plan with 10,000 events a month and up to 3 sites, no card needed&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;Make a free account at &lt;a href="https://privatusanalytics.com" rel="noopener noreferrer"&gt;privatusanalytics.com&lt;/a&gt;. Start on one site. Check the &lt;a href="https://privatusanalytics.com/pricing" rel="noopener noreferrer"&gt;pricing page&lt;/a&gt; if you ever grow past the free plan. The plugin code is open on &lt;a href="https://github.com/Privatus-Analytics/wordpress" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>wordpress</category>
      <category>analytics</category>
      <category>privacy</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How to Add Privacy-Friendly Analytics to a Next.js App in 5 Minutes (No Cookie Banner)</title>
      <dc:creator>Privatus Analytics</dc:creator>
      <pubDate>Mon, 26 Oct 2026 02:07:32 +0000</pubDate>
      <link>https://dev.to/privatusanalytics/how-to-add-privacy-friendly-analytics-to-a-nextjs-app-in-5-minutes-no-cookie-banner-29cg</link>
      <guid>https://dev.to/privatusanalytics/how-to-add-privacy-friendly-analytics-to-a-nextjs-app-in-5-minutes-no-cookie-banner-29cg</guid>
      <description>&lt;p&gt;You ship a Next.js app. You want to know if anyone uses it. So you add Google Analytics.&lt;/p&gt;

&lt;p&gt;Then the trouble starts. You add a cookie pop-up, because the tool tracks people. Some visitors click "no". Their visits vanish from your numbers. Other visitors just get annoyed and leave. The reports are slow and hard to read. And every visit is sent to Google, which you may not want to do to your users.&lt;/p&gt;

&lt;p&gt;There is a simpler way. In this tutorial you will add a small analytics script to a Next.js app. It sets no tracking cookies. It filters out bots. It takes about five minutes.&lt;/p&gt;

&lt;p&gt;We will use &lt;a href="https://privatusanalytics.com" rel="noopener noreferrer"&gt;Privatus Analytics&lt;/a&gt;. It is a web analytics tool that does not use cookies. Other tools like Plausible, Fathom and Umami work in a similar way, so pick what fits you. I will show the steps for Privatus Analytics because that is what I know best.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you need
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A Next.js app. Either the App Router or the Pages Router works.&lt;/li&gt;
&lt;li&gt;A free Privatus Analytics account. The free plan gives you 10,000 events a month and up to 3 sites. You do not need a card.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An "event" is one thing that gets counted, like a page view or a button click.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Add your site and copy the site ID
&lt;/h2&gt;

&lt;p&gt;Sign in and add your site. You will get a site ID that looks like &lt;code&gt;pa_7Q2K9XH3AB&lt;/code&gt;. Copy it. It is not a secret. It is printed in the page for everyone to see, just like the ID of any other analytics tool.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://privatusanalytics.com/docs/getting-started/add-a-site" rel="noopener noreferrer"&gt;Add a site guide&lt;/a&gt; shows each click if you get lost.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Put your site ID in an environment variable
&lt;/h2&gt;

&lt;p&gt;Open &lt;code&gt;.env.local&lt;/code&gt; in the root of your project and add this line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;NEXT_PUBLIC_PA_SITE_ID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;pa_YOURSITEID
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Swap in your real ID. The &lt;code&gt;NEXT_PUBLIC_&lt;/code&gt; part is a Next.js rule. It tells Next.js that this value may be used in the browser.&lt;/p&gt;

&lt;p&gt;Restart your dev server after you save the file. Next.js only reads this file when it starts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Add the script (App Router)
&lt;/h2&gt;

&lt;p&gt;Open &lt;code&gt;app/layout.tsx&lt;/code&gt;. Add the &lt;code&gt;Script&lt;/code&gt; component from &lt;code&gt;next/script&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Script&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;next/script&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;RootLayout&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;children&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ReactNode&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;html&lt;/span&gt; &lt;span class="na"&gt;lang&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Script&lt;/span&gt;
          &lt;span class="na"&gt;defer&lt;/span&gt;
          &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://privatusstats.com/js/pa.js"&lt;/span&gt;
          &lt;span class="na"&gt;data-site&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NEXT_PUBLIC_PA_SITE_ID&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
          &lt;span class="na"&gt;data-modules&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"engage,auto,vitals,clicks,ask"&lt;/span&gt;
          &lt;span class="na"&gt;strategy&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"afterInteractive"&lt;/span&gt;
        &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;html&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let me explain the parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;src&lt;/code&gt; is the tracking script.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;data-site&lt;/code&gt; tells the script which site the numbers belong to.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;data-modules&lt;/code&gt; turns on extra features. &lt;code&gt;engage&lt;/code&gt; measures time on a page and how far people scroll. &lt;code&gt;vitals&lt;/code&gt; measures how fast your pages feel. &lt;code&gt;clicks&lt;/code&gt; records where people click. If you only want page views, you can remove this line. The &lt;a href="https://privatusanalytics.com/docs/tracker/attributes" rel="noopener noreferrer"&gt;script attributes page&lt;/a&gt; lists every option.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;strategy="afterInteractive"&lt;/code&gt; makes Next.js load the script after the page is ready. It will not slow down your first paint.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Using the Pages Router instead?
&lt;/h3&gt;

&lt;p&gt;Put the same &lt;code&gt;&amp;lt;Script&amp;gt;&lt;/code&gt; in &lt;code&gt;pages/_app.tsx&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;AppProps&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;next/app&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Script&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;next/script&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;MyApp&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;pageProps&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="nx"&gt;AppProps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Component&lt;/span&gt; &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;pageProps&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Script&lt;/span&gt;
        &lt;span class="na"&gt;defer&lt;/span&gt;
        &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://privatusstats.com/js/pa.js"&lt;/span&gt;
        &lt;span class="na"&gt;data-site&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NEXT_PUBLIC_PA_SITE_ID&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
        &lt;span class="na"&gt;strategy&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"afterInteractive"&lt;/span&gt;
      &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: Check that page changes are counted
&lt;/h2&gt;

&lt;p&gt;Next.js does not reload the whole page when someone clicks a link. It changes the page with JavaScript. Many old analytics setups miss these clicks.&lt;/p&gt;

&lt;p&gt;You do not need extra code here. The script follows these changes by default. The setting is called &lt;code&gt;data-spa&lt;/code&gt; and its default is &lt;code&gt;auto&lt;/code&gt;. So a visitor who clicks through five pages is counted as five page views.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Test it on your computer
&lt;/h2&gt;

&lt;p&gt;By default the script does not send anything from &lt;code&gt;localhost&lt;/code&gt;. This keeps your own testing out of your numbers. But then you see nothing while you build.&lt;/p&gt;

&lt;p&gt;To see what would be sent, add &lt;code&gt;data-debug="true"&lt;/code&gt; to the script for now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Script&lt;/span&gt;
  &lt;span class="na"&gt;defer&lt;/span&gt;
  &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://privatusstats.com/js/pa.js"&lt;/span&gt;
  &lt;span class="na"&gt;data-site&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NEXT_PUBLIC_PA_SITE_ID&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
  &lt;span class="na"&gt;data-debug&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"true"&lt;/span&gt;
  &lt;span class="na"&gt;strategy&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"afterInteractive"&lt;/span&gt;
&lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open your browser console and click around. The script prints each hit instead of sending it. Remove &lt;code&gt;data-debug&lt;/code&gt; when you are happy.&lt;/p&gt;

&lt;p&gt;Then deploy. Visit your live site and look at the dashboard. The &lt;a href="https://privatusanalytics.com/docs/getting-started/verify-installation" rel="noopener noreferrer"&gt;Verify the installation guide&lt;/a&gt; tells you what a good result looks like.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6 (optional): Track a button click
&lt;/h2&gt;

&lt;p&gt;Page views are a good start. But you may want to know how many people click "Upgrade". The script puts a small object on &lt;code&gt;window.privatus&lt;/code&gt;. You call &lt;code&gt;track&lt;/code&gt; on it.&lt;/p&gt;

&lt;p&gt;Make a client component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;use client&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;UpgradeButton&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;
      &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;privatus&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nf"&gt;track&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Upgrade&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;plan&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pro&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      Upgrade
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;?.&lt;/code&gt; means "only call this if it exists". So your button still works if a visitor uses an ad blocker.&lt;/p&gt;

&lt;p&gt;The second part, &lt;code&gt;{ plan: 'pro' }&lt;/code&gt;, is a property. It is extra detail that you can later use to split your numbers, like "Upgrade clicks by plan".&lt;/p&gt;

&lt;p&gt;If you use TypeScript, you will see an error because &lt;code&gt;window.privatus&lt;/code&gt; is not known. The &lt;a href="https://privatusanalytics.com/docs/tracker/javascript-api#typescript" rel="noopener noreferrer"&gt;JavaScript API page&lt;/a&gt; has a short type declaration you can copy.&lt;/p&gt;

&lt;h2&gt;
  
  
  About the cookie pop-up
&lt;/h2&gt;

&lt;p&gt;The Privatus Analytics script does not set tracking cookies. So the script itself does not need a cookie pop-up. The only thing it can store in the browser is a small "do not track me" flag, and only if a visitor asks for it.&lt;/p&gt;

&lt;p&gt;Rules about this are different in each country, and your other tools may still need a pop-up. So check the rules where your visitors live. But for your analytics, there is one less thing to ask people about.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why bots matter
&lt;/h2&gt;

&lt;p&gt;Many numbers in old analytics tools are padded with bots. These are programs that visit your pages. They are not people. Privatus Analytics checks every visit against rules for known crawlers, test tools, and servers in big data centers. Bots are kept out of your reports and do not count against your event limit. The &lt;a href="https://privatusanalytics.com/docs/features/bot-filtering" rel="noopener noreferrer"&gt;bot filtering page&lt;/a&gt; lists every rule.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you get
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A working analytics setup in one file, with no extra packages&lt;/li&gt;
&lt;li&gt;Page views that follow Next.js page changes&lt;/li&gt;
&lt;li&gt;No tracking cookies, so no pop-up for this tool&lt;/li&gt;
&lt;li&gt;Bot visits filtered out of your numbers&lt;/li&gt;
&lt;li&gt;Optional click and button tracking with one line of code&lt;/li&gt;
&lt;li&gt;Visitor data that is not sent to Google&lt;/li&gt;
&lt;li&gt;A free plan with 10,000 events a month and up to 3 sites, no card needed&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;You can set this up on a side project tonight. The free plan needs no card, and the script is one tag. Start at &lt;a href="https://privatusanalytics.com" rel="noopener noreferrer"&gt;privatusanalytics.com&lt;/a&gt; and see the &lt;a href="https://privatusanalytics.com/pricing" rel="noopener noreferrer"&gt;pricing page&lt;/a&gt; for what each plan includes.&lt;/p&gt;

&lt;p&gt;The Next.js guide is in the &lt;a href="https://privatusanalytics.com/docs/install/nextjs" rel="noopener noreferrer"&gt;docs&lt;/a&gt;. If you find a problem, the tracker code and plugins live in the &lt;a href="https://github.com/Privatus-Analytics" rel="noopener noreferrer"&gt;Privatus Analytics GitHub organization&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>analytics</category>
      <category>privacy</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
