Count pageviews with LopeBase
Add one tag to a site and LopeBase counts its pageviews, visits, sources, and the signups and sales each source brings, with no cookies or visitor ids.
You do not need PostHog, Google Analytics, or Plausible to see pageviews in LopeBase. One tag, and LopeBase counts them itself: pages, visit sources, and visits, with no cookies and no visitor id, working alongside anything else you already have connected.
Add the tag
-
Open Analytics
Pick the property, then copy its tag from "Count pageviews with LopeBase" at the end of the page. It shows until the tag counts its first hit.
Open Analytics -
Add it to your site
Put the tag once in the layout every page shares, inside
<head>, however your framework does that:app/layout.tsxfor Next.js's app router,pages/_document.tsxfor its pages router, the shared layout for Astro,src/app.htmlfor SvelteKit, and so on. There is also a ready-made prompt for your coding agent to do this for you. -
Deploy and check
Numbers show on Analytics within a minute of the first visit after you deploy.
The tag looks like this, with your property's own key: <script defer src="https://app.lopebase.com/lb.js" data-site="your-site-key"></script>
How it counts
Each page load sends one hit, and so does every page change inside a single-page app, without a full reload. The visit's first touch (its source, a search engine, a link, or utm_source, plus utm_medium, utm_campaign, and the page it started on) is kept only in that browser tab's sessionStorage for the rest of the visit, never in a cookie, and no visitor id is ever set. The visit's first page also sends its utm_campaign, so each campaign's visits are counted, the way an email campaign's Stats show them. A link from your own site, its www address, or one of its subdomains is not counted as a source. Hits are only accepted from the property's own site address, using a key that names the property but carries no secret.
Because there is no cookie and nothing to consent to, pageviews counted this way need no cookie banner, and the ad blockers that hide other analytics tools rarely block it.
What you see
Once hits arrive, Analytics shows pageviews and visits over the last 30 days, pages per visit, your top traffic source, a daily chart, and breakdowns of top pages and sources, the same shape as any other analytics source LopeBase reads.
Count signups and sales by source
With the tag on your site, call lopebase.conversion in the browser when someone converts, once it has succeeded:
lopebase.conversion("signup");
lopebase.conversion("purchase", { value: 49 });
LopeBase credits each conversion to the visit's first touch: the source, medium, and campaign it arrived with and the page it landed on. Pick the property on Analytics to see Conversions by source, by landing page, and by campaign, with each source's visits beside its conversions.
- Names are lowercase letters, digits, and
_ . : -, up to 40 characters, likesignup,trial_start, orpurchase. valueis optional: the amount in your site's own currency, from 0 to 1,000,000. LopeBase adds values up as you send them and does not convert currencies.- Nothing about the person is sent or kept, only the count and value per day.
- If a call can happen before the tag's script has loaded, add this line before the tag, and those calls are sent once it loads:
<script>window.lopebase=window.lopebase||{q:[],conversion:function(){window.lopebase.q.push(arguments)}};</script>
Agents get the same calls from get_pageview_snippet and read the results with get_pageviews.
With or without the adapter
Pageviews and conversions work whether or not a property has the LopeBase Adapter installed. An app with the adapter can also report where its customers came from, counted in its own database; see Show where customers come from.
Where to go next
- Connect your tools for PostHog, Google Analytics, or Plausible if you already use one of them.
- Analytics for everything else the page shows.
- Install the LopeBase Adapter to add your app's own users and signups.
If something goes wrong
Something else? Contact us.
No numbers show up after adding the tag
Check that the tag is on every page, inside the shared layout rather than just one page, and that you deployed after adding it. It can take a minute after the first real visit for numbers to appear.
Add LopeBase's site address on the property first
The property needs a site address before LopeBase can issue it a tag. Add one on the property's own page, then come back to Analytics.
Will this need a cookie banner?
No. It sets no cookie and no visitor id, so there is nothing that needs consent.
Conversions do not show up
Check that the page calling lopebase.conversion also has the tag, that the name uses only lowercase letters, digits, and _ . : -, and that value, if you pass one, is a number. A call with a bad name or value is dropped. A call made before the script loads is only kept with the line above added before the tag.
Why is my own site listed as a source?
It should not be: links from your site, its www address, and its subdomains count as part of the visit. Older visits recorded before this change may still show it for a while.
Can I use this alongside PostHog or Google Analytics?
Yes. It runs independently of any other analytics connection; Analytics shows each source's numbers on their own.