Install
Put this line on the page once. Replace YOUR_ORIGIN with your collection host and YOUR_SITE_KEY with the site key.
<script async src="https://YOUR_ORIGIN/w.js" data-site="YOUR_SITE_KEY"></script>A second copy on the same page is ignored. The chat widget is loaded from w-chat.js in the same directory when needed. Do not add another tag. See Chat widget (w-chat.js).
Initialize
There is no init function. With data-site set, the script sends the first pageview when the document is ready and hooks later URL changes. Add data-hash="true" on the same tag for hash routing. Add data-auto-track="false" when you will send pageviews yourself.
Pageviews
With autocapture on, the first load and later URL changes each send a pageview. The same URL is not sent twice. Call webcount.pageview() when you need to send one yourself. Single-page apps are in Pageviews & SPAs.
Events
webcount.track('purchase', { revenue: 19.9, currency: 'CNY' });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.
Identity
At first, webcount only has track and pageview. In identify mode, the first pageview response loads w-id.js from the same directory. After that:
webcount.login('USER_ID', { plan: 'pro' }, { type: 'login' });
webcount.logout();Email and mobile values are hashed first. An empty id, an id over 200 characters, or a placeholder id returns immediately. Collection tiers are in Identify users.
Limits
| Item | Default | What happens |
|---|---|---|
| Privacy signals | Honored | Do Not Track or Global Privacy Control stops collection. Add data-respect-dnt="false" to turn this off |
| Local hosts | Skipped | Local hostnames such as localhost and 127.* are not sent. Add data-allow-local="true" or set data-api explicitly to send anyway |
| Script errors | Silent | Internal failures are not thrown into the page |
Errors
Without data-site the script returns immediately and no request appears. A collect response does not by itself mean the event is stored. Check the realtime report. See Verify your installation.