SiteViews Logo

The Simplest Way to Show Page Views

Track page views and gather visitor information effortlessly with
react-siteviews
. Fully customizable, with zero backend setup required.
React
Next.js
TypeScript
Customizable

Get Started in Minutes

Choose your preferred technology stack and start tracking page views

SiteViews Counter Template

You are in Version siteviews@2.2.1

index.html

<!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>

Output

Views:

About siteviews Script

Attributes

AttributePriorityDescription
src*required-highCDN URL pointing to the SiteViews package. Never modify this value.
type*required-highMust be "application/javascript" so the browser executes SiteViews correctly.
scriptfor*required-highMust be set to "siteviews" so the package can locate and initialize itself.
project-name*required-lowUnique project identifier used to track and store view counts per project.
output-element-id*required-highID of the element where the view count will be rendered on the page.
defer*required-lowDefers script execution until the DOM is fully parsed. Highly recommended to ensure the output element exists before SiteViews initializes.
refresh (Second)optionalRe-fetches the view count at a set interval. Minimum value is 10 seconds.
toastoptionalShows a toast notification only on the user's first visit. Omit if unnecessary.
suppressLogsoptionalSilences all SiteViews console logs and warnings. Recommended for production use.
If you do not provide the * marked attributes, the counter will not work correctly.

What’s new in Version 2.2.1?

  • The implementation remains the same as before.
  • Refactored the codebase by applying best practices and improving type safety.

Frequently Asked Questions

Everything you need to know about SiteViews

Love 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

View Your Site Stats

Enter your access key to explore last week's visitor data

Access Key for Last Week Stats
Enter your access key to view stats

Don't have or Expired access key?

0
Loading...