
Choose your preferred technology stack and start tracking page views
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>SiteViews Template</title>
</head>
<body>
<div>
<p>Views: <span id="views">Loading...</span></p>
</div>
<!-- include siteviews script tags -->
<script
src="https://unpkg.com/siteviews@2.2.1/dist/index.js"
type="application/javascript"
scriptfor="siteviews"
project-name="my-project"
output-element-id="views"
defer
refresh="10"
toast
suppressLogs
></script>
</body>
</html>Views:
| Attribute | Priority | Description |
|---|---|---|
| src* | required-high | CDN URL pointing to the SiteViews package. Never modify this value. |
| type* | required-high | Must be "application/javascript" so the browser executes SiteViews correctly. |
| scriptfor* | required-high | Must be set to "siteviews" so the package can locate and initialize itself. |
| project-name* | required-low | Unique project identifier used to track and store view counts per project. |
| output-element-id* | required-high | ID of the element where the view count will be rendered on the page. |
| defer* | required-low | Defers script execution until the DOM is fully parsed. Highly recommended to ensure the output element exists before SiteViews initializes. |
| refresh (Second) | optional | Re-fetches the view count at a set interval. Minimum value is 10 seconds. |
| toast | optional | Shows a toast notification only on the user's first visit. Omit if unnecessary. |
| suppressLogs | optional | Silences all SiteViews console logs and warnings. Recommended for production use. |
Everything you need to know about SiteViews
If you find this project helpful, consider giving it a star on GitHub. Your support helps us grow and improve!
Open source and free forever
Enter your access key to explore last week's visitor data
Don't have or Expired access key?