Plain HTML
Add tracking to static HTML websites
For static HTML websites, integrating PureStats is straightforward. Simply add the tracking code to your HTML template.
Basic Integration
Add the following code to your HTML file's <head> section:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Website</title>
<!-- Your stylesheets -->
<link rel="stylesheet" href="styles.css">
<!-- PureStats Analytics -->
<script defer data-domain="yourdomain.com" src="https://purestats.io/pf.min.js"></script>
</head>
<body>
<!-- Your content -->
</body>
</html>
Multi-Page Websites
If your website has multiple HTML files, you have two options:
Option 1: Add to each page
Copy the script tag to the <head> section of each HTML file. This is simple but can be tedious for large sites.
Option 2: Use a template system
If you're using any kind of templating (PHP includes, server-side includes, etc.), add the tracking code to your header template so it's automatically included on all pages.
Tracking Custom Events
You can track custom events like button clicks directly in your HTML:
<!-- Track a button click -->
<button onclick="purestats('Download Click')">
Download PDF
</button>
<!-- Track a link click -->
<a href="/signup" onclick="purestats('Signup Click')">
Sign Up Now
</a>
<!-- Track form submission -->
<form onsubmit="purestats('Contact Form')">
<!-- form fields -->
<button type="submit">Submit</button>
</form>
Automatic Tracking
PureStats automatically tracks:
- Pageviews - Every page load is tracked automatically
- Outbound links - Clicks to external websites
- File downloads - Downloads of PDF, ZIP, DOC, and other common file types
- 404 errors - Pages that return a 404 error