HTML访问计数器代码:任何网站的复制粘贴代码片段(2026)
2026年有效的HTML访问计数器代码片段——适用于WordPress、Shopify、Webflow、Ghost、Substack、Squarespace以及普通HTML。复制、粘贴,60秒完成。
You want to add a hit counter to your website and you want the HTML hit counter code to copy-paste. This guide gives you exactly that — working snippets for every major website platform in 2026, with no signup steps mixed in.
If you just want the canonical "drop it anywhere" snippet, here's the free hit counter one-liner:
<script async src="https://feed-pulse.com/api/embed/hit_counter?site_id=YOUR_SITE_ID"></script>Replace YOUR_SITE_ID with the ID you'll get when generating the widget at feed-pulse.com/free-hit-counter (no signup, ~30 seconds). The rest of this guide shows where to paste it on every major platform plus a few advanced configurations.
Universal HTML hit counter snippet
The single <script async> tag below is the FeedPulse hit counter. It works on every site that allows HTML or script embeds.
<script async src="https://feed-pulse.com/api/embed/hit_counter?site_id=YOUR_SITE_ID"></script>Default rendering: a small pill showing today's count and all-time count.
To customize the display, add query params:
<!-- Show only all-time count -->
<script async src="https://feed-pulse.com/api/embed/hit_counter?site_id=YOUR_SITE_ID&show=total"></script>
<!-- Retro/classic odometer style -->
<script async src="https://feed-pulse.com/api/embed/hit_counter?site_id=YOUR_SITE_ID&theme=retro"></script>
<!-- Today only, dark theme -->
<script async src="https://feed-pulse.com/api/embed/hit_counter?site_id=YOUR_SITE_ID&show=today&theme=dark"></script>Full param list is in the hit counter customizer.
Platform-by-platform paste locations
WordPress
For the entire site (footer, sidebar, every page):
- WP Admin → Appearance → Widgets.
- Add a Custom HTML widget to the sidebar or footer widget area.
- Paste the snippet.
- Save.
For a single post or page:
- Edit the post/page.
- In the block editor, add a Custom HTML block.
- Paste the snippet.
- Publish.
Shopify
- Online Store → Themes → click Customize on your active theme.
- Theme settings → Custom CSS or Custom HTML (depending on theme).
- For a global counter (footer): paste in theme.liquid before
</body>. Edit code: Themes → ⋯ → Edit code →layout/theme.liquid.
For a specific page (e.g., Contact):
- Pages → Edit → Show HTML mode → paste snippet inline.
Webflow
- Project Settings → Custom Code → Footer Code.
- Paste the snippet.
- Save & publish.
For a specific page:
- Drag an Embed component onto the page.
- Paste the snippet inside the embed code editor.
- Save & publish.
Ghost
For the entire site:
- Settings → Code injection → Site Footer.
- Paste the snippet.
- Save.
For a single post:
- Edit the post.
- Add an HTML card ( "/" → "HTML").
- Paste the snippet.
- Publish.
Substack
- Edit any post or page.
- Switch to HTML mode (gear icon → "Raw HTML").
- Paste the snippet inline.
- Publish.
(Substack restricts script tags in some contexts. If the script doesn't load, contact Substack support to allow custom widgets, which they grant to most legitimate sites.)
Wix
- Edit your site.
- Drag the HTML Code element (under "Embed" or "Add" menu) onto the page.
- Paste the snippet in the code editor.
- Save & publish.
Squarespace
- Edit the page where you want the counter.
- Add a Code Block.
- Paste the snippet.
- Save & publish.
Plain HTML (any static site)
Open your HTML file in any editor. Paste the snippet anywhere inside <body> (or in the <head> if you want it loaded earlier).
<!DOCTYPE html>
<html>
<head>
<title>My site</title>
</head>
<body>
<p>Welcome to my site.</p>
<!-- Hit counter widget -->
<script async src="https://feed-pulse.com/api/embed/hit_counter?site_id=YOUR_SITE_ID"></script>
</body>
</html>Astro, Next.js, Nuxt, Gatsby (modern frameworks)
For static/server-rendered React/Vue frameworks, the snippet goes inside the corresponding layout file. In Next.js:
import Script from 'next/script';
export default function Layout({ children }) {
return (
<>
{children}
<Script
src="https://feed-pulse.com/api/embed/hit_counter?site_id=YOUR_SITE_ID"
strategy="afterInteractive"
/>
</>
);
}In Astro / 11ty / Hugo, paste the original <script async> tag into your base layout template.
What to paste where (cheat sheet)
| Platform | Best location | Specific UI path |
|---|---|---|
| WordPress | Sidebar / Footer widget | Appearance → Widgets → Custom HTML |
| Shopify | Footer | Edit code → theme.liquid before </body> |
| Webflow | Footer code | Project Settings → Custom Code → Footer |
| Ghost | Site footer | Settings → Code injection → Site Footer |
| Substack | Inline in post | Raw HTML mode |
| Wix | Page element | Add → Embed → HTML Code |
| Squarespace | Page block | Add block → Code Block |
| Plain HTML | Anywhere in body | Inside <body> tag |
| Next.js | Layout component | <Script> from next/script |
| Astro/11ty/Hugo | Base layout | Inside base template |
Common mistakes pasting HTML hit counter code
- Pasting into a "rich text" field instead of "HTML" mode. Most page editors have a "preview" vs "HTML" toggle. The snippet only works in HTML mode — otherwise the script tag is escaped as text.
- Modifying the
asyncattribute. Don't remove it. Without async, the script blocks page render — Lighthouse score drops, Core Web Vitals degrade. Always keep async. - Pasting in
<head>when the platform expects<body>and vice versa. Some platforms (WordPress widgets, Webflow embeds) only run scripts in specific locations. Follow the platform-specific guidance above. - Using the same
site_idfor multiple sites. Counts will be combined across all sites using that ID. Generate a separate ID per site. - Wrapping the snippet in extra
<div>tags. Unnecessary — the script self-renders into a container at the paste location.
What if the snippet doesn't appear?
Five things to check, in order:
- Did you paste in HTML mode, not rich-text mode? Confirm by looking at the raw saved content; the
<script` tag should be present. - Does your platform allow script tags? Substack and Medium restrict by default. WordPress.com (the hosted version) restricts scripts on free plans. Most other platforms allow them.
- Is your
site_idcorrect? A typo means the snippet calls a nonexistent endpoint and silently fails. - Is an ad-blocker hiding the widget? Some aggressive blockers hide all third-party scripts. Test in incognito with extensions disabled.
- Is Content Security Policy (CSP) blocking the script? Sites with strict CSP headers may block external script sources. Add
feed-pulse.comto yourscript-srcdirective.
Frequently asked questions
Do I need to know HTML to add a hit counter?
No — you just need to know how to paste text into the right field in your site editor. The platform-by-platform sections above guide you to that field for every major site builder.
Does the HTML hit counter code work on free WordPress.com plans?
The free WordPress.com plan blocks most third-party scripts. The counter works on:
- Self-hosted WordPress (any plan)
- WordPress.com Premium plan and above
- WordPress.org self-hosted
If you're on free WordPress.com, you'll need to upgrade or use a built-in WordPress.com stats widget instead.
Can I customize the look of the hit counter via the HTML code?
You customize via the URL query params in the script tag (?theme=retro, ?show=total, etc.). The hit counter customizer generates the exact URL with all your settings baked in — easier than editing the query string by hand.
Will the hit counter slow my page?
The async loading attribute ensures the script doesn't block page render. The widget adds <2KB and loads after the rest of the page. Lighthouse impact is negligible.
Can I use the same HTML hit counter code on multiple sites?
You can, but counts will be summed across all sites. To track each site separately, generate a unique site_id per site at feed-pulse.com/free-hit-counter. Each site_id is its own counter.
Is there a no-JavaScript HTML hit counter?
For static page counters (e.g., for users with JS disabled), you'd need a server-side render — typically a small <img> pixel that increments a count via the image request. This works on platforms where you can host server-side code; FeedPulse doesn't offer a JS-free fallback in 2026 because <0.2% of browsers in 2026 have JS disabled.
Are the FeedPulse hit counter scripts GDPR-compliant?
Yes — no cookies are set, IPs are anonymized at the source before processing, and no PII is stored. GDPR and CCPA safe by default. No cookie banner update needed.
Generate your hit counter snippet
If you don't already have your site_id, open feed-pulse.com/free-hit-counter, enter your domain, customize the theme, and copy the generated snippet. ~30 seconds. For a complete visitor-engagement set on your blog or portfolio, pair the hit counter with the live traffic feed and flag counter. All free, no signup.