More in Getting started
- Install TapCub on your website
- Migrate from Google Analytics 4 or Baidu Tongji
- Add a website, app or mini-program
- How do I add TapCub to WordPress?
- How do I add TapCub to Shopify?
- Where do I paste the TapCub tracking code?
- Can I install TapCub with Google Tag Manager?
- How do I track a React, Vue or Next.js app?
- How do I check that TapCub is collecting data?
- Why does TapCub show no data after I installed it?
- What is a site, and how many can I add?
- Which time zone should I pick for a site?
- Which domains do I need to register?
- How do I keep my own visits out of the reports?
- Why does my visitor count differ from Google Analytics 4?
- Can I run TapCub alongside Google Analytics 4?
- How do I move my goals and events from GA4?
- Can I import my historical data from GA4?
- How do I add TapCub to Squarespace?
- How do I add TapCub to Wix?
- Which Content Security Policy rules does TapCub need?
- Do ad blockers block TapCub?
- How do I send events from my server?
- How do I install TapCub on React?
- How do I install TapCub on Vue?
- How do I install TapCub on Next.js?
- How do I capture a HAR file for TapCub support?
- How do I create and manage API keys?
- How do I send events with the HTTP API?
- All guides in this category
Still have a question?
Could not find it? A person reads every message, usually within a few hours on business days.
Chat with usShort answer
Add the TapCub script tag once to the head, through app.head in nuxt.config (Nuxt 3) or in app.html. The first document and client navigations are tracked automatically. Call tapcub.track and tapcub.login only in browser code; there is no tapcub during server rendering.
Short answer
Add the TapCub script tag once to the document head: through app.head in nuxt.config (Nuxt 3), or in app.html. It tracks the first document and client navigations; call tapcub only in the browser, never in server code.
Find your site key in Web analytics › Configuration › SDK code.
1. Add the script once
In Nuxt 3, add it to nuxt.config:
// nuxt.config.ts
export default defineNuxtConfig({
app: {
head: {
script: [
{ src: 'https://static.pathclue.com/client.js', defer: true, 'data-site': 'YOUR_SITE_KEY' },
],
},
},
})
In a project with an app.html template, put the same tag in its head instead:
<script defer src="https://static.pathclue.com/client.js" data-site="YOUR_SITE_KEY"></script>
The script starts in the browser by itself. Do not create or inject it again from a component; a second insert is ignored.
2. Pageviews and route changes
The first load and later route changes that use browser history are sent automatically. For hash routing, add data-hash="true" to the same tag.
To send pageviews yourself, set data-auto-track="false" on the script and call tapcub.pageview() after each route finishes. Note that this also turns off automatic outbound and download clicks, Web Vitals and 404 events. See install on single-page apps.
3. Events and sign-in
tapcub.track('purchase', { revenue: 19.9 });
Call it from a click handler on the client, not from server middleware or a server plugin: during server rendering there is no tapcub object. Event names are cut at 100 characters; at most 20 properties are kept, keys are cut at 50 characters and string values at 200. Only strings, numbers and booleans are kept as values.
After sign-in, link the visitor to your user ID:
tapcub.login(userId, { plan: 'pro' }, { type: 'login' });
login comes from the identity script, so check that it exists before calling it. More in identify users.
Check it works
Local hostnames such as localhost are skipped by default, which is easy to mistake for a broken install. Test on a deployed preview or the live site, watch the browser network panel for the collect request, then follow check your installation.
Common problems
| Symptom | Cause | Fix |
|---|---|---|
| Error in a server plugin | tapcub does not exist on the server | Move the call to client code |
| No request in server logs | Collection runs in the browser | Watch the browser network panel |
| No requests during local development | Localhost is skipped | Test on a deployed URL |
| Only the first pageview | Hash routes without data-hash="true" | Add it to the same tag |
| Properties missing | Over 20 properties, or object values | Send flat strings, numbers or booleans |
Not using Nuxt? See install TapCub.
Did this answer your question?
We use your answers to fix and expand this page.
Couldn’t send. Please try again in a minute.
Thanks for the feedback. We’ll use it to improve this page.You’ve already sent feedback on this page. Thanks.